Unknown error when using t.boolean in io-ts with polyfact library
Closed this issue · 1 comments
kevin-btc commented
I'm working on a project using io-ts
(version 2.2.20) and the polyfact
SDK (version 0.1.7) on Node.js (v19.4.0) with TypeScript on macOS. When trying to generate a reference type using generateWithTypeWithTokenUsage
, I encounter an unknown error. It seems to be related to the use of t.boolean
.
Steps to Reproduce
- Define the various types and the
ReferenceType
as shown below:
const ReferenceParameter = t.type({
name: t.string,
type: t.string,
description: t.string,
});
const ErrorType = t.type({
name: t.string,
description: t.string,
});
const ReturnsType = t.type({
type: t.string,
description: t.string,
});
const Example = t.type({
title: t.string,
description: t.string,
example: t.string,
});
const TReference: t.Any = t.type({
name: t.string,
prototype: t.string,
enum: t.array(t.string),
description: t.string,
keywords: t.array(t.string),
parameters: t.array(ReferenceParameter),
returns: ReturnsType,
public: t.boolean,
errors: t.array(ErrorType),
});
const ReferenceType = t.type({
description: t.string,
references: t.array(TReference),
examples: t.array(Example),
});
- Attempt to generate a reference type with the
ReferenceType
:
try {
reference = String(
await generateWithTypeWithTokenUsage(prompt, ReferenceType)
);
} catch (error) {
console.log(ReferenceType, error);
}
Expected Result
The ReferenceType
should be generated successfully.
Actual Result
An unknown error is thrown, as shown below:
InterfaceType {...} Error: An unknown error occurred
at new GenerationError (/Users/kev/Projects/ai-docs-package/node_modules/polyfact/dist/index.js:119:32)
at /Users/kev/Projects/ai-docs-package/node_modules/polyfact/dist/index.js:150:31
...`
Additional Context
The error appears to be related to t.boolean
, as removing it eliminates the error. We're not sure why this type in particular is causing an issue.
lowczarc commented
It was a bug on the API side. It should now be solved.