Skip to content

Commit

Permalink
fix (@ai-sdk/azure): allow for nullish delta (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Jun 11, 2024
1 parent 2b6cc6d commit fc9552e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-jokes-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ai-sdk/openai': patch
---

fix (@ai-sdk/azure): allow for nullish delta
2 changes: 1 addition & 1 deletion examples/ai-core/src/stream-text/azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dotenv.config();

async function main() {
const result = await streamText({
model: azure('v0-gpt-35-turbo'), // use your own deployment
model: azure('gpt-4o'), // use your own deployment
prompt: 'Invent a new holiday and describe its traditions.',
});

Expand Down
34 changes: 18 additions & 16 deletions packages/openai/src/openai-chat-language-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,23 +458,25 @@ const openaiChatChunkSchema = z.union([
z.object({
choices: z.array(
z.object({
delta: z.object({
role: z.enum(['assistant']).optional(),
content: z.string().nullish(),
tool_calls: z
.array(
z.object({
index: z.number(),
id: z.string().nullish(),
type: z.literal('function').optional(),
function: z.object({
name: z.string().nullish(),
arguments: z.string().nullish(),
delta: z
.object({
role: z.enum(['assistant']).optional(),
content: z.string().nullish(),
tool_calls: z
.array(
z.object({
index: z.number(),
id: z.string().nullish(),
type: z.literal('function').optional(),
function: z.object({
name: z.string().nullish(),
arguments: z.string().nullish(),
}),
}),
}),
)
.nullish(),
}),
)
.nullish(),
})
.nullish(),
logprobs: z
.object({
content: z
Expand Down

0 comments on commit fc9552e

Please sign in to comment.