Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Conversation

@transitive-bullshit
Copy link
Contributor

z.literal('gpt-3.5-turbo-0301'),
z.literal('gpt-3.5-turbo-16k'),
z.string(),
]);
Copy link
Collaborator

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(),
Copy link
Collaborator

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 🤔

Copy link
Contributor Author

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?

@wong2
Copy link

wong2 commented Jun 14, 2023

Maybe we can use https://zod.dev/?id=passthrough to allow unrecognized keys? This allows adopting new parameters faster for users.

rileytomasek added a commit that referenced this pull request Jun 14, 2023
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)
@rileytomasek
Copy link
Collaborator

Moved to #27

rileytomasek added a commit that referenced this pull request Jun 15, 2023
* 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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants