[mirotalksfu] - update ChatGPT to latest
هذا الالتزام موجود في:
@@ -135,12 +135,12 @@ const defaultStats = {
|
|||||||
let chatGPT;
|
let chatGPT;
|
||||||
if (config.chatGPT.enabled) {
|
if (config.chatGPT.enabled) {
|
||||||
if (config.chatGPT.apiKey) {
|
if (config.chatGPT.apiKey) {
|
||||||
const { Configuration, OpenAIApi } = require('openai');
|
const { OpenAI } = require('openai');
|
||||||
const configuration = new Configuration({
|
const configuration = {
|
||||||
basePath: config.chatGPT.basePath,
|
basePath: config.chatGPT.basePath,
|
||||||
apiKey: config.chatGPT.apiKey,
|
apiKey: config.chatGPT.apiKey,
|
||||||
});
|
};
|
||||||
chatGPT = new OpenAIApi(configuration);
|
chatGPT = new OpenAI(configuration);
|
||||||
} else {
|
} else {
|
||||||
log.warning('ChatGPT seems enabled, but you missing the apiKey!');
|
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!');
|
if (!config.chatGPT.enabled) return cb('ChatGPT seems disabled, try later!');
|
||||||
try {
|
try {
|
||||||
// https://platform.openai.com/docs/api-reference/completions/create
|
// 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',
|
model: config.chatGPT.model || 'text-davinci-003',
|
||||||
prompt: prompt,
|
prompt: prompt,
|
||||||
max_tokens: config.chatGPT.max_tokens,
|
max_tokens: config.chatGPT.max_tokens,
|
||||||
temperature: config.chatGPT.temperature,
|
temperature: config.chatGPT.temperature,
|
||||||
});
|
});
|
||||||
const response = completion.data.choices[0].text;
|
const response = completion.choices[0].text;
|
||||||
log.debug('ChatGPT', {
|
log.debug('ChatGPT', {
|
||||||
time: time,
|
time: time,
|
||||||
room: room,
|
room: room,
|
||||||
@@ -1036,12 +1036,18 @@ function startServer() {
|
|||||||
});
|
});
|
||||||
cb(response);
|
cb(response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response) {
|
if (error instanceof OpenAI.APIError) {
|
||||||
log.error('ChatGPT', error.response.data);
|
log.error('ChatGPT', {
|
||||||
cb(error.response.data.error.message);
|
status: error.status,
|
||||||
} else {
|
message: error.message,
|
||||||
log.error('ChatGPT', error.message);
|
code: error.code,
|
||||||
|
type: error.type,
|
||||||
|
});
|
||||||
cb(error.message);
|
cb(error.message);
|
||||||
|
} else {
|
||||||
|
// Non-API error
|
||||||
|
log.error('ChatGPT', error);
|
||||||
|
cb(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"mediasoup": "3.12.10",
|
"mediasoup": "3.12.10",
|
||||||
"mediasoup-client": "3.6.99",
|
"mediasoup-client": "3.6.99",
|
||||||
"ngrok": "^4.3.3",
|
"ngrok": "^4.3.3",
|
||||||
"openai": "^3.3.0",
|
"openai": "^4.2.0",
|
||||||
"qs": "6.11.2",
|
"qs": "6.11.2",
|
||||||
"socket.io": "4.7.2",
|
"socket.io": "4.7.2",
|
||||||
"swagger-ui-express": "5.0.0",
|
"swagger-ui-express": "5.0.0",
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم