-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add chat functions support #26
Conversation
| z.literal('gpt-3.5-turbo-0301'), | ||
| z.literal('gpt-3.5-turbo-16k'), | ||
| z.string(), | ||
| ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can replace this with z.string(). The string part of the union makes the rest useless from a Zod perspective. I did it for autocompletion, but it doesn't actually work.
| /** The name of the function to call. */ | ||
| name: z.string(), | ||
| /** The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ | ||
| arguments: z.string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node library types has name and arguments values as optional and the API reference docs don't specify 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I'm not sure; I guess we should make them optional to guarantee that zod doesn't complain?
|
Maybe we can use https://zod.dev/?id=passthrough to allow unrecognized keys? This allows adopting new parameters faster for users. |
Using [`passthrough()`](https://zod.dev/?id=passthrough) will allow users to pass params that we haven't added to the Zod params schemas. Zod strips unknown keys from objects without this. Thanks: #26 (comment)
|
Moved to #27 |
* feat: add chat functions support * fix: add exports * fix: ChatMessage.content can now be null * Improve ChatMessage schemas/types Stricter support for narrowing/inference by using a union of the many variants of ChatMessage. * Add passthrough to all Zod parsing of params Using [`passthrough()`](https://zod.dev/?id=passthrough) will allow users to pass params that we haven't added to the Zod params schemas. Zod strips unknown keys from objects without this. Thanks: #26 (comment) * Export new ChatMessage types and schemas These will likely be helpful when working with the ChatMessage data before making the request. * Improve usability of function types --------- Co-authored-by: Travis Fischer <fisch0920@gmail.com>
https://openai.com/blog/function-calling-and-other-api-updates