fix(all): Fix search on others bots than boot.
This commit is contained in:
parent
c8ae34bc71
commit
b619cdc219
4 changed files with 29 additions and 15 deletions
|
@ -97,7 +97,7 @@
|
||||||
"botlib": "3.0.11",
|
"botlib": "3.0.11",
|
||||||
"c3-chart-maker": "0.2.8",
|
"c3-chart-maker": "0.2.8",
|
||||||
"cd": "0.3.3",
|
"cd": "0.3.3",
|
||||||
"chatgpt": "2.4.2",
|
"chatgpt": "^2.4.2",
|
||||||
"chrome-remote-interface": "0.31.3",
|
"chrome-remote-interface": "0.31.3",
|
||||||
"cli-progress": "3.11.2",
|
"cli-progress": "3.11.2",
|
||||||
"cli-spinner": "0.2.10",
|
"cli-spinner": "0.2.10",
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
"npm": "9.6.1",
|
"npm": "9.6.1",
|
||||||
"open": "8.4.0",
|
"open": "8.4.0",
|
||||||
"open-docxtemplater-image-module": "1.0.3",
|
"open-docxtemplater-image-module": "1.0.3",
|
||||||
"openai": "3.3.0",
|
"openai": "4.6.0",
|
||||||
"pdf-extraction": "1.0.2",
|
"pdf-extraction": "1.0.2",
|
||||||
"pdf-to-png-converter": "3.1.0",
|
"pdf-to-png-converter": "3.1.0",
|
||||||
"pdfkit": "0.13.0",
|
"pdfkit": "0.13.0",
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { GBMinInstance } from 'botlib';
|
import { GBMinInstance } from 'botlib';
|
||||||
import { Configuration, OpenAIApi } from "openai";
|
import OpenAI from "openai";
|
||||||
|
import { ChatGPTAPIBrowser, getOpenAIAuth } from 'chatgpt'
|
||||||
|
|
||||||
export class ChatServices {
|
export class ChatServices {
|
||||||
/**
|
/**
|
||||||
|
@ -45,22 +46,24 @@ export class ChatServices {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static async continue(min: GBMinInstance, text: string, chatId) {
|
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) {
|
if (!key) {
|
||||||
throw new Error('Open AI Key not configured in .gbot.');
|
throw new Error('Open AI Key not configured in .gbot.');
|
||||||
}
|
}
|
||||||
|
const openai = new OpenAI({
|
||||||
const configuration = new Configuration({
|
apiKey: key
|
||||||
apiKey: key,
|
|
||||||
});
|
});
|
||||||
const openai = new OpenAIApi(configuration);
|
const chatCompletion = await openai.chat.completions.create({
|
||||||
|
|
||||||
const chatCompletion = await openai.createChatCompletion({
|
|
||||||
model: "gpt-3.5-turbo",
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
const answersCreated = await GuaribasAnswer.bulkCreate(answers);
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
|
@ -59,8 +59,6 @@ import * as winston from 'winston-logs-display';
|
||||||
import { RootData } from './RootData.js';
|
import { RootData } from './RootData.js';
|
||||||
import { GBSSR } from '../packages/core.gbapp/services/GBSSR.js';
|
import { GBSSR } from '../packages/core.gbapp/services/GBSSR.js';
|
||||||
import { Mutex } from 'async-mutex';
|
import { Mutex } from 'async-mutex';
|
||||||
import { GBVMService } from '../packages/basic.gblib/services/GBVMService.js';
|
|
||||||
import e from 'express';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General Bots open-core entry point.
|
* General Bots open-core entry point.
|
||||||
|
@ -78,6 +76,8 @@ export class GBServer {
|
||||||
GBConfigService.init();
|
GBConfigService.init();
|
||||||
const port = GBConfigService.getServerPort();
|
const port = GBConfigService.getServerPort();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (process.env.TEST_SHELL) {
|
if (process.env.TEST_SHELL) {
|
||||||
GBLog.info(`Running TEST_SHELL: ${process.env.TEST_SHELL}...`);
|
GBLog.info(`Running TEST_SHELL: ${process.env.TEST_SHELL}...`);
|
||||||
try {
|
try {
|
||||||
|
@ -139,6 +139,7 @@ export class GBServer {
|
||||||
|
|
||||||
const mainCallback = () => {
|
const mainCallback = () => {
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GBLog.info(`Now accepting connections on ${port}...`);
|
GBLog.info(`Now accepting connections on ${port}...`);
|
||||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
||||||
|
|
Loading…
Add table
Reference in a new issue