-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): add more API request tests
- Loading branch information
1 parent
ad89892
commit 04c1590
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,6 +444,50 @@ describe('.parse()', () => { | |
"type": "object", | ||
} | ||
`); | ||
|
||
const completion = await makeSnapshotRequest( | ||
(openai) => | ||
openai.beta.chat.completions.parse({ | ||
model: 'gpt-4o-2024-08-06', | ||
messages: [ | ||
{ | ||
role: 'system', | ||
content: 'You are a helpful assistant.', | ||
}, | ||
{ | ||
role: 'user', | ||
content: | ||
'jane doe, born nov 16, engineer at openai, [email protected]. john smith, born march 1, enigneer at openai, [email protected]', | ||
}, | ||
], | ||
response_format: zodResponseFormat(contactPersonSchema, 'contactPerson'), | ||
}), | ||
2, | ||
); | ||
|
||
expect(completion.choices[0]?.message).toMatchInlineSnapshot(` | ||
{ | ||
"content": "{"person1":{"name":"Jane Doe","phone_number":"+1234567890","roles":["other"],"description":"Engineer at OpenAI. Email: [email protected]"},"person2":{"name":"John Smith","phone_number":"+0987654321","differentField":"Engineer at OpenAI. Email: [email protected]"}}", | ||
"parsed": { | ||
"person1": { | ||
"description": "Engineer at OpenAI. Email: [email protected]", | ||
"name": "Jane Doe", | ||
"phone_number": "+1234567890", | ||
"roles": [ | ||
"other", | ||
], | ||
}, | ||
"person2": { | ||
"differentField": "Engineer at OpenAI. Email: [email protected]", | ||
"name": "John Smith", | ||
"phone_number": "+0987654321", | ||
}, | ||
}, | ||
"refusal": null, | ||
"role": "assistant", | ||
"tool_calls": [], | ||
} | ||
`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters