fix(all): Fix search on others bots than boot.

This commit is contained in:
Rodrigo Rodriguez 2023-09-10 20:40:42 -03:00
parent c8ae34bc71
commit b619cdc219
4 changed files with 29 additions and 15 deletions

View file

@ -97,7 +97,7 @@
"botlib": "3.0.11",
"c3-chart-maker": "0.2.8",
"cd": "0.3.3",
"chatgpt": "2.4.2",
"chatgpt": "^2.4.2",
"chrome-remote-interface": "0.31.3",
"cli-progress": "3.11.2",
"cli-spinner": "0.2.10",
@ -136,7 +136,7 @@
"npm": "9.6.1",
"open": "8.4.0",
"open-docxtemplater-image-module": "1.0.3",
"openai": "3.3.0",
"openai": "4.6.0",
"pdf-extraction": "1.0.2",
"pdf-to-png-converter": "3.1.0",
"pdfkit": "0.13.0",

View file

@ -33,7 +33,8 @@
'use strict';
import { GBMinInstance } from 'botlib';
import { Configuration, OpenAIApi } from "openai";
import OpenAI from "openai";
import { ChatGPTAPIBrowser, getOpenAIAuth } from 'chatgpt'
export class ChatServices {
/**
@ -45,22 +46,24 @@ export class ChatServices {
*
*/
public static async continue(min: GBMinInstance, text: string, chatId) {
let key = min.core.getParam(min.instance, 'Open AI Key', null);
let key;
if (process.env.OPENAI_KEY) {
key = process.env.OPENAI_KEY;
}
else {
key = min.core.getParam(min.instance, 'Open AI Key', null);
}
if (!key) {
throw new Error('Open AI Key not configured in .gbot.');
}
const configuration = new Configuration({
apiKey: key,
const openai = new OpenAI({
apiKey: key
});
const openai = new OpenAIApi(configuration);
const chatCompletion = await openai.createChatCompletion({
const chatCompletion = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{role: "user", content: text}],
messages: [{ role: "user", content: text }],
});
return chatCompletion.data.choices[0].message.content;
return chatCompletion.choices[0].message.content;
}
}

View file

@ -585,6 +585,16 @@ export class KBService implements IGBKBService {
}
});
await GuaribasQuestion.destroy({
where: { instanceId: min.instance.instanceId }
});
await GuaribasAnswer.destroy({
where: { instanceId: min.instance.instanceId }
});
await GuaribasSubject.destroy({
where: { instanceId: min.instance.instanceId}
});
const answersCreated = await GuaribasAnswer.bulkCreate(answers);
let i = 0;

View file

@ -59,8 +59,6 @@ import * as winston from 'winston-logs-display';
import { RootData } from './RootData.js';
import { GBSSR } from '../packages/core.gbapp/services/GBSSR.js';
import { Mutex } from 'async-mutex';
import { GBVMService } from '../packages/basic.gblib/services/GBVMService.js';
import e from 'express';
/**
* General Bots open-core entry point.
@ -78,6 +76,8 @@ export class GBServer {
GBConfigService.init();
const port = GBConfigService.getServerPort();
if (process.env.TEST_SHELL) {
GBLog.info(`Running TEST_SHELL: ${process.env.TEST_SHELL}...`);
try {
@ -139,6 +139,7 @@ export class GBServer {
const mainCallback = () => {
(async () => {
try {
GBLog.info(`Now accepting connections on ${port}...`);
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';