Skip to content

Commit 74d8d76

Browse files
committed
chore: Migrate from strict to strictObject
1 parent 7b59aec commit 74d8d76

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

sample-code/src/orchestration.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,15 @@ export interface TranslationResponse {
572572
* @returns Response that adheres to `TranslationResponse` type.
573573
*/
574574
export async function orchestrationResponseFormat(): Promise<TranslationResponse> {
575-
const translationSchema = z
576-
.object({
577-
language: z.string().meta({
578-
description:
579-
'The language of the translation, randomly chosen by the LLM.'
580-
}),
581-
translation: z
582-
.string()
583-
.meta({ description: 'The translation of the input sentence.' })
584-
})
585-
.strict();
575+
const translationSchema = z.strictOject({
576+
language: z.string().meta({
577+
description:
578+
'The language of the translation, randomly chosen by the LLM.'
579+
}),
580+
translation: z
581+
.string()
582+
.meta({ description: 'The translation of the input sentence.' })
583+
});
586584
const orchestrationClient = new OrchestrationClient({
587585
// define the language model to be used
588586
promptTemplating: {
@@ -621,12 +619,10 @@ export async function orchestrationResponseFormat(): Promise<TranslationResponse
621619
return JSON.parse(response.getContent()!) as TranslationResponse;
622620
}
623621

624-
const addNumbersSchema = z
625-
.object({
626-
a: z.number().meta({ description: 'The first number to be added.' }),
627-
b: z.number().meta({ description: 'The second number to be added.' })
628-
})
629-
.strict();
622+
const addNumbersSchema = z.strictObject({
623+
a: z.number().meta({ description: 'The first number to be added.' }),
624+
b: z.number().meta({ description: 'The second number to be added.' })
625+
});
630626

631627
const addNumbersTool: ChatCompletionTool = {
632628
type: 'function',

test-util/tools.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ export const addNumbersSchemaV3 = zodV3
1515
/**
1616
* @internal
1717
*/
18-
export const addNumbersSchema = zodV4
19-
.object({
20-
a: zodV4.number().meta({ description: 'The first number to be added.' }),
21-
b: zodV4.number().meta({ description: 'The second number to be added.' })
22-
})
23-
.strict();
18+
export const addNumbersSchema = zodV4.strictObject({
19+
a: zodV4.number().meta({ description: 'The first number to be added.' }),
20+
b: zodV4.number().meta({ description: 'The second number to be added.' })
21+
});
2422

2523
/**
2624
* @internal
@@ -37,12 +35,10 @@ export const addNumbersTool: ChatCompletionTool = {
3735
/**
3836
* @internal
3937
*/
40-
const multiplyNumbersSchema = zodV4
41-
.object({
42-
a: zodV4.number().meta({ description: 'The first number to multiply.' }),
43-
b: zodV4.number().meta({ description: 'The second number to multiply.' })
44-
})
45-
.strict();
38+
const multiplyNumbersSchema = zodV4.strictObject({
39+
a: zodV4.number().meta({ description: 'The first number to multiply.' }),
40+
b: zodV4.number().meta({ description: 'The second number to multiply.' })
41+
});
4642

4743
/**
4844
* @internal

0 commit comments

Comments
 (0)