-
Notifications
You must be signed in to change notification settings - Fork 24
Add function calling support to chat completions #27
Conversation
Stricter support for narrowing/inference by using a union of the many variants of ChatMessage.
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)
These will likely be helpful when working with the ChatMessage data before making the request.
|
@rileytomasek What would you think about merging and releasing as-is via a minor version bump? I know it's technically a breaking change, so we'd ideally want to combine this with the streaming support, but I think it's more important to get it released. |
I'm fine with that. I think it would only be a breaking change at the types level, if at all. |
|
LGTM 👍 |
|
Released as v1.6.0 |
|
I'm getting some undesired type errors after the latest updates:
// this gives a type error
if (completion.message.function_call) { ... }// this works fine
if (completion.message.role === 'assistant' && completion.message.completion.message.function_call) { ... }@rileytomasek I think both of these should work type-wise. Another unrelated error where I'm less sure what's going on is that it seems like using an array of
|
This makes the various ChatMessage types slightly less strict, which should make them easier to work with, but still not allow for strictly incorrect usage. Should fix: #27 (comment)
This makes the various ChatMessage types slightly less strict, which should make them easier to work with, but still not allow for strictly incorrect usage. Should fix: #27 (comment)



This continues from #26
Adds support for function calling:
Todo: