-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
137 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
/** | ||
* GenAIScript supporting runtime | ||
*/ | ||
import { delay as esDelay } from "es-toolkit" | ||
import { delay as _delay } from "es-toolkit" | ||
import { z as zod } from "zod" | ||
|
||
/** | ||
* A helper function to delay the execution of the script | ||
*/ | ||
export const delay: (ms: number) => Promise<void> = esDelay | ||
export const delay: (ms: number) => Promise<void> = _delay | ||
|
||
/** | ||
* Zod schema generator | ||
*/ | ||
export const z = zod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { zodToJsonSchema as _zodToJsonSchema } from "zod-to-json-schema" | ||
|
||
/** | ||
* Converts a Zod schema to a JSON schema | ||
* @param z | ||
* @param options | ||
* @returns | ||
*/ | ||
export function tryZodToJsonSchema( | ||
z: ZodTypeLike, | ||
options?: object | ||
): JSONSchema { | ||
if (!z || !z._def || !z.refine || !z.safeParse) return undefined | ||
const schema = _zodToJsonSchema(z as any, { | ||
target: "openAi", | ||
...(options || {}), | ||
}) | ||
return structuredClone(schema) as JSONSchema | ||
} |
Oops, something went wrong.