Skip to content

Commit 2f06c89

Browse files
committed
throws faster
1 parent 0801b56 commit 2f06c89

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/lib/tools/BetaToolRunnerE2E.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,36 @@ describe('toolRunner integration tests', () => {
316316
expect(['blue', 'black', 'gray', 'grey']).toContain(color); // ai is bad at colours apparently
317317
});
318318
});
319+
320+
it('top level non-object schemas throw', async () => {
321+
await expect(async () => {
322+
// At least for now, openai does not support non-object schemas at top level
323+
const runner = client.beta.chat.completions.toolRunner({
324+
model: 'gpt-4o',
325+
max_tokens: 1000,
326+
max_iterations: 5,
327+
messages: [
328+
{
329+
role: 'user',
330+
content:
331+
'Use the array_tool with the array ["hello", "world"], then provide a final response that includes the word \'foo\'.',
332+
},
333+
],
334+
tools: [
335+
betaZodFunctionTool({
336+
name: 'array_tool',
337+
description: 'Tool for array operations',
338+
parameters: z.array(z.string()).describe('Array of strings'),
339+
run: async (input: string[]) => {
340+
return input.map((item) => item.toUpperCase()).join(', ');
341+
},
342+
}),
343+
],
344+
});
345+
const messages = [];
346+
for await (const message of runner) {
347+
messages.push(message);
348+
}
349+
}).rejects.toThrow();
350+
});
319351
});

0 commit comments

Comments
 (0)