mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 19:54:13 +00:00
(test) proxy - add JS OpenAI test
This commit is contained in:
parent
04db5b7bbf
commit
b4218439a5
1 changed files with 31 additions and 0 deletions
31
litellm/proxy/tests/test_openai_js.js
Normal file
31
litellm/proxy/tests/test_openai_js.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
const openai = require('openai');
|
||||||
|
|
||||||
|
// set DEBUG=true in env
|
||||||
|
process.env.DEBUG=false;
|
||||||
|
async function runOpenAI() {
|
||||||
|
const client = new openai.OpenAI({
|
||||||
|
apiKey: 'your_api_key_here',
|
||||||
|
baseURL: 'http://0.0.0.0:8000'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await client.chat.completions.create({
|
||||||
|
model: 'azure-gpt-3.5',
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: 'user',
|
||||||
|
content: 'this is a test request, write a short poem'.repeat(2000),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("got this exception from server");
|
||||||
|
console.error(error);
|
||||||
|
console.log("done with exception from proxy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the asynchronous function
|
||||||
|
runOpenAI();
|
Loading…
Add table
Add a link
Reference in a new issue