From 2f93c755b881309d1ec547f96f64552e117632bd Mon Sep 17 00:00:00 2001 From: Alexandr Sekerin Date: Thu, 28 Dec 2023 00:37:08 +0300 Subject: [PATCH] feat: modify openai models to generate text and images --- src/openai.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/openai.js b/src/openai.js index 3f97c49..e3375c4 100644 --- a/src/openai.js +++ b/src/openai.js @@ -17,12 +17,17 @@ class OpenAIApi { apiKey: apiKey, httpAgent: new HttpsProxyAgent(proxyUrl), }); + this.models = { + generateText: 'gpt-3.5-turbo-1106', + transcription: 'whisper-1', + createImages: 'dall-e-2', + }; } async chat(messages) { const response = await this.openai.chat.completions.create({ messages, - model: 'gpt-3.5-turbo', + model: this.models.generateText, }); return response.choices[0].message; @@ -31,14 +36,14 @@ class OpenAIApi { async transcription(filepath) { const response = await this.openai.audio.transcriptions.create({ file: createReadStream(filepath), - model: 'whisper-1', + model: this.models.transcription, }); return response.text; } async getImage(text, size, count) { const response = await this.openai.images.generate({ - model: 'dall-e-3', + model: this.models.createImages, prompt: text, n: count, size: size,