Skip to content

Instantly share code, notes, and snippets.

@ma-zah
Created September 29, 2023 14:52
Show Gist options
  • Save ma-zah/2674f361eafa2a9741fc1b65e8ed7ae9 to your computer and use it in GitHub Desktop.
Save ma-zah/2674f361eafa2a9741fc1b65e8ed7ae9 to your computer and use it in GitHub Desktop.
on type safety in LangChain TS
async call(
arg: (z.output<T> extends string ? string : never) | z.input<T>,
configArg?: Callbacks | RunnableConfig,
/** @deprecated */
tags?: string[]
): Promise<string> {
let parsed;
try {
parsed = await this.schema.parseAsync(arg);
} catch (e) {
throw new ToolInputParsingException(
`Received tool input did not match expected schema`,
JSON.stringify(arg)
);
}
// ... more code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment