Skip to content

Commit

Permalink
feat: add json-schema-to-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
lucgagan committed Jun 27, 2023
1 parent 837e786 commit 536013c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"ajv": "^8.12.0",
"json-schema-to-ts": "^2.9.1",
"ts-custom-error": "^3.3.1",
"zod": "^3.21.4"
},
Expand Down
3 changes: 2 additions & 1 deletion src/createChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { retry } from "./retry";
import { omit } from "./omit";
import { createUserFunction, type UserFunction } from "./createUserFunction";
import Ajv, { AnySchemaObject } from "ajv";
import { type FromSchema } from "json-schema-to-ts";

type JsonValue =
| JsonObject
Expand Down Expand Up @@ -164,7 +165,7 @@ export const createChat = (

type SendMessageReturn<T> = T extends undefined
? Choice
: StructuredChoice<JsonObject>;
: StructuredChoice<FromSchema<T["expect"]["schema"]>>;

function sendMessage<T extends MessageOptions>(
prompt: string,
Expand Down

0 comments on commit 536013c

Please sign in to comment.