Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down