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

Commit

Permalink
update openai tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patcher9 committed Feb 11, 2024
1 parent 60a3655 commit bfe9903
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/openai.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ describe('OpenAI Test', () => {
openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
await DokuMetry.init({llm: openai, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
});

it('should return a response with object as "chat.completion"', 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 chatCompletion = await openai.chat.completions.create({
messages: [{role: 'user', content: 'Say this is a test'}],
model: 'gpt-3.5-turbo',
Expand All @@ -23,6 +23,7 @@ describe('OpenAI Test', () => {
});

it('should return a response with object as "text_completion"', 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 completion = await openai.completions.create({
model: 'gpt-3.5-turbo-instruct',
prompt: 'Say this is a test.',
Expand All @@ -33,6 +34,7 @@ describe('OpenAI Test', () => {
});

it('should return a response with object as "embedding"', 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 embeddings = await openai.embeddings.create({
model: 'text-embedding-ada-002',
input: 'The quick brown fox jumped over the lazy dog',
Expand All @@ -43,6 +45,7 @@ describe('OpenAI Test', () => {
});

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',
Expand All @@ -59,6 +62,7 @@ describe('OpenAI Test', () => {
}).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.',
Expand All @@ -68,6 +72,7 @@ describe('OpenAI Test', () => {
}).timeout(30000);

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 imageVariation = await openai.images.createVariation({
image: fs.createReadStream('tests/test-image-for-openai.png'),
});
Expand All @@ -76,6 +81,7 @@ describe('OpenAI Test', () => {
}).timeout(30000);

it('should return a response with url as "https://api.openai.com/v1/audio/speech"', 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 audioSpeech = await openai.audio.speech.create({
model: 'tts-1',
voice: 'alloy',
Expand Down

0 comments on commit bfe9903

Please sign in to comment.