Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/anthropic-ai/sdk-0.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
patcher9 authored Mar 27, 2024
2 parents 0106ba6 + eac2432 commit 34c8053
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main" ]
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
- cron: '0 0 1-31/15 * *'

env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_TOKEN }}
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 25 additions & 19 deletions tests/openai.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('OpenAI Test', () => {
const chatCompletion = await openai.chat.completions.create({
messages: [{role: 'user', content: 'What is LLM Monitoring?'}],
model: 'gpt-3.5-turbo',
max_tokens: 1,
});

expect(chatCompletion.object).to.equal('chat.completion');
Expand All @@ -27,7 +28,7 @@ describe('OpenAI Test', () => {
const completion = await openai.completions.create({
model: 'gpt-3.5-turbo-instruct',
prompt: 'What is LLM Observability?',
max_tokens: 7,
max_tokens: 1,
});

expect(completion.object).to.equal('text_completion');
Expand All @@ -37,35 +38,37 @@ describe('OpenAI Test', () => {
await DokuMetry.init({llm: openai, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
const embeddings = await openai.embeddings.create({
model: 'text-embedding-ada-002',
input: 'The quick brown fox jumped over the lazy dog',
input: 'LLM Observability',
encoding_format: 'float',
});

expect(embeddings.data[0].object).to.equal('embedding');
}).timeout(30000);;

it('should return a response with object as "fine_tuning.job"', async () => {
await DokuMetry.init({llm: openai, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
try {
const fineTuningJob = await openai.fineTuning.jobs.create({
training_file: 'file-m36cc45komO83VJKAY1qVgeP',
model: 'gpt-3.5-turbo',
});
// it('should return a response with object as "fine_tuning.job"', async () => {
// await DokuMetry.init({llm: openai, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
// try {
// const fineTuningJob = await openai.fineTuning.jobs.create({
// training_file: '',
// model: 'gpt-3.5-turbo',
// });

expect(fineTuningJob.object).to.equal('fine_tuning.job');
} catch (error) {
// Check if it's a rate limit error
if (error.code == "daily_rate_limit_exceeded") {
console.error(`Daily Rate limit Reached`);
}
}
}).timeout(10000);
// expect(fineTuningJob.object).to.equal('fine_tuning.job');
// } catch (error) {
// // Check if it's a rate limit error
// if (error.code == "daily_rate_limit_exceeded") {
// console.error(`Daily Rate limit Reached`);
// }
// }
// }).timeout(10000);

it('should return a response with "created" field', async () => {
await DokuMetry.init({llm: openai, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
const imageGeneration = await openai.images.generate({
model: 'dall-e-2',
prompt: 'Generate an image of a cat.',
prompt: 'LLM Observability dashboard',
size: "256x256",
n: 1
});

expect(imageGeneration.created).to.exist;
Expand All @@ -75,6 +78,9 @@ describe('OpenAI Test', () => {
await DokuMetry.init({llm: openai, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
const imageVariation = await openai.images.createVariation({
image: fs.createReadStream('tests/test-image-for-openai.png'),
size: "256x256",
model: 'dall-e-2',
n: 1
});

expect(imageVariation.created).to.exist;
Expand All @@ -85,7 +91,7 @@ describe('OpenAI Test', () => {
const audioSpeech = await openai.audio.speech.create({
model: 'tts-1',
voice: 'alloy',
input: 'Today is a wonderful day to build something people love!',
input: 'LLM Observability',
});
expect(audioSpeech.url).to.equal('https://api.openai.com/v1/audio/speech');
}).timeout(30000);
Expand Down

0 comments on commit 34c8053

Please sign in to comment.