[mirotalksfu] - update ChatGPT to latest
هذا الالتزام موجود في:
@@ -135,12 +135,12 @@ const defaultStats = {
|
||||
let chatGPT;
|
||||
if (config.chatGPT.enabled) {
|
||||
if (config.chatGPT.apiKey) {
|
||||
const { Configuration, OpenAIApi } = require('openai');
|
||||
const configuration = new Configuration({
|
||||
const { OpenAI } = require('openai');
|
||||
const configuration = {
|
||||
basePath: config.chatGPT.basePath,
|
||||
apiKey: config.chatGPT.apiKey,
|
||||
});
|
||||
chatGPT = new OpenAIApi(configuration);
|
||||
};
|
||||
chatGPT = new OpenAI(configuration);
|
||||
} else {
|
||||
log.warning('ChatGPT seems enabled, but you missing the apiKey!');
|
||||
}
|
||||
@@ -1020,13 +1020,13 @@ function startServer() {
|
||||
if (!config.chatGPT.enabled) return cb('ChatGPT seems disabled, try later!');
|
||||
try {
|
||||
// https://platform.openai.com/docs/api-reference/completions/create
|
||||
const completion = await chatGPT.createCompletion({
|
||||
const completion = await chatGPT.completions.create({
|
||||
model: config.chatGPT.model || 'text-davinci-003',
|
||||
prompt: prompt,
|
||||
max_tokens: config.chatGPT.max_tokens,
|
||||
temperature: config.chatGPT.temperature,
|
||||
});
|
||||
const response = completion.data.choices[0].text;
|
||||
const response = completion.choices[0].text;
|
||||
log.debug('ChatGPT', {
|
||||
time: time,
|
||||
room: room,
|
||||
@@ -1036,12 +1036,18 @@ function startServer() {
|
||||
});
|
||||
cb(response);
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
log.error('ChatGPT', error.response.data);
|
||||
cb(error.response.data.error.message);
|
||||
} else {
|
||||
log.error('ChatGPT', error.message);
|
||||
if (error instanceof OpenAI.APIError) {
|
||||
log.error('ChatGPT', {
|
||||
status: error.status,
|
||||
message: error.message,
|
||||
code: error.code,
|
||||
type: error.type,
|
||||
});
|
||||
cb(error.message);
|
||||
} else {
|
||||
// Non-API error
|
||||
log.error('ChatGPT', error);
|
||||
cb(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم