fix (templates): llm-server almost OK.
This commit is contained in:
parent
25882854f8
commit
55e3334cc3
15 changed files with 71 additions and 54 deletions
|
@ -1354,9 +1354,9 @@ export class DialogKeywords {
|
||||||
return messages.join('\n');
|
return messages.join('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
count = 0;
|
count = 0;
|
||||||
GBLog.error(`API Message Pooling error: ${GBUtil.toYAML(err)}`);
|
GBLog.error(`API Message Pooling error: ${GBUtil.toYAML(error)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -511,7 +511,9 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
const jsfile: string = `${filename}.js`;
|
const jsfile: string = `${filename}.js`;
|
||||||
|
|
||||||
code = (await fs.readFile('./vm-inject.js')).toString();
|
const template = (await fs.readFile('./vm-inject.js')).toString();
|
||||||
|
code = template.replace('//##INJECTED_CODE_HERE', code );
|
||||||
|
code = template.replace('//##INJECTED_HEADER', `port=${GBVMService.API_PORT}; botId='${min.botId}';` );
|
||||||
|
|
||||||
code = ji.default(code, ' ');
|
code = ji.default(code, ' ');
|
||||||
|
|
||||||
|
|
|
@ -925,8 +925,8 @@ export class SystemKeywords {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
retries: 5,
|
retries: 5,
|
||||||
onRetry: err => {
|
onRetry: error => {
|
||||||
GBLog.error(`Retrying HTTP GET due to: ${err.message}.`);
|
GBLog.error(`Retrying HTTP GET due to: ${error.message}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1842,8 +1842,8 @@ export class SystemKeywords {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
retries: 5,
|
retries: 5,
|
||||||
onRetry: err => {
|
onRetry: error => {
|
||||||
GBLog.error(`Retrying HTTP GET due to: ${err.message}.`);
|
GBLog.error(`Retrying HTTP GET due to: ${error.message}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -2198,8 +2198,8 @@ export class SystemKeywords {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
retries: 5,
|
retries: 5,
|
||||||
onRetry: err => {
|
onRetry: error => {
|
||||||
GBLog.error(`MERGE: Retrying SELECT ALL on table: ${err.message}.`);
|
GBLog.error(`MERGE: Retrying SELECT ALL on table: ${error.message}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -2591,8 +2591,8 @@ export class SystemKeywords {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
retries: 5,
|
retries: 5,
|
||||||
onRetry: err => {
|
onRetry: error => {
|
||||||
GBLog.error(`Retrying deleteFromStorage due to: ${err.message}.`);
|
GBLog.error(`Retrying deleteFromStorage due to: ${error.message}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -2853,8 +2853,8 @@ export class SystemKeywords {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
retries: 5,
|
retries: 5,
|
||||||
onRetry: err => {
|
onRetry: error => {
|
||||||
GBLog.error(`Retrying SaveToStorage due to: ${err.message}.`);
|
GBLog.error(`Retrying SaveToStorage due to: ${error.message}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -251,8 +251,8 @@ export const createVm2Pool = ({ min, max, ...limits }) => {
|
||||||
await client.Runtime.enable();
|
await client.Runtime.enable();
|
||||||
|
|
||||||
resolve(1);
|
resolve(1);
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
GBLog.error(err);
|
GBLog.error(error);
|
||||||
kill(childProcess);
|
kill(childProcess);
|
||||||
GBServer.globals.debuggers[limits.botId].state = 0;
|
GBServer.globals.debuggers[limits.botId].state = 0;
|
||||||
GBServer.globals.debuggers[limits.botId].stateInfo = 'Stopped';
|
GBServer.globals.debuggers[limits.botId].stateInfo = 'Stopped';
|
||||||
|
|
|
@ -398,7 +398,7 @@ await fs.writeFile('.env', env);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
instance.params = JSON.stringify(JSON.parse(instance.params));
|
instance.params = JSON.stringify(JSON.parse(instance.params));
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
instance.params = JSON.stringify(instance.params);
|
instance.params = JSON.stringify(instance.params);
|
||||||
}
|
}
|
||||||
return await instance.save();
|
return await instance.save();
|
||||||
|
|
|
@ -835,11 +835,11 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await search.deleteDataSource(dsName);
|
await search.deleteDataSource(dsName);
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
// If it is a 404 there is nothing to delete as it is the first creation.
|
// If it is a 404 there is nothing to delete as it is the first creation.
|
||||||
|
|
||||||
if (err.code !== 404) {
|
if (error.code !== 404) {
|
||||||
throw err;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -847,11 +847,11 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await search.deleteIndex();
|
await search.deleteIndex();
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
// If it is a 404 there is nothing to delete as it is the first creation.
|
// If it is a 404 there is nothing to delete as it is the first creation.
|
||||||
|
|
||||||
if (err.code !== 404 && err.code !== 'OperationNotAllowed') {
|
if (error.code !== 404 && error.code !== 'OperationNotAllowed') {
|
||||||
throw err;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,9 +859,9 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString);
|
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString);
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
GBLog.error(err);
|
GBLog.error(error);
|
||||||
throw err;
|
throw error;
|
||||||
}
|
}
|
||||||
await search.createIndex(searchSchema, dsName);
|
await search.createIndex(searchSchema, dsName);
|
||||||
|
|
||||||
|
|
|
@ -1218,6 +1218,7 @@ export class GBMinService {
|
||||||
const context = adapter['createContext'](req);
|
const context = adapter['createContext'](req);
|
||||||
context['_activity'] = context.activity.body;
|
context['_activity'] = context.activity.body;
|
||||||
await handler(context);
|
await handler(context);
|
||||||
|
|
||||||
// Return status
|
// Return status
|
||||||
res.status(200);
|
res.status(200);
|
||||||
|
|
||||||
|
@ -1230,7 +1231,7 @@ export class GBMinService {
|
||||||
GBLog.error('Calling processActivity due to Signing Key could not be retrieved error.');
|
GBLog.error('Calling processActivity due to Signing Key could not be retrieved error.');
|
||||||
await adapter['processActivity'](req, res, handler);
|
await adapter['processActivity'](req, res, handler);
|
||||||
} else {
|
} else {
|
||||||
|
GBLog.error(`Error processing activity: ${GBUtil.toYAML(error)}`);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1637,7 +1638,7 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
data.step = null;
|
data.step = null;
|
||||||
GBLogEx.info(min, `/answer being called from processMessageActivity (nextDialog=${nextDialog}).`);
|
GBLogEx.info(min, `/answer from processMessageActivity (nextDialog=${nextDialog}).`);
|
||||||
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
||||||
data: data,
|
data: data,
|
||||||
query: text,
|
query: text,
|
||||||
|
|
|
@ -164,7 +164,7 @@ export const getRouter = (
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
router.post(`/api/messages/${botId}/v3/conversations/:conversationId/activities/:activityId`, (req, res) => {
|
router.post(`/v3/conversations/:conversationId/activities/:activityId`, (req, res) => {
|
||||||
let activity: IActivity;
|
let activity: IActivity;
|
||||||
|
|
||||||
activity = req.body;
|
activity = req.body;
|
||||||
|
|
|
@ -188,8 +188,8 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
});
|
});
|
||||||
watermark = response.obj.watermark;
|
watermark = response.obj.watermark;
|
||||||
await this.printMessages(response.obj.activities, conversationId, threadName, from, fromName);
|
await this.printMessages(response.obj.activities, conversationId, threadName, from, fromName);
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
GBLog.error(`Error calling printMessages on GoogleChat channel ${err.data === undefined ? err : err.data}`);
|
GBLog.error(`Error calling printMessages on GoogleChat channel ${GBUtil.toYAML(error)}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setInterval(worker, this.pollInterval);
|
setInterval(worker, this.pollInterval);
|
||||||
|
|
|
@ -226,15 +226,21 @@ export class AskDialog extends IGBDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const results: any = await service.ask(
|
let results;
|
||||||
min,
|
try {
|
||||||
user,
|
results = await service.ask(
|
||||||
step,
|
min,
|
||||||
step.context.activity['pid'],
|
user,
|
||||||
text,
|
step,
|
||||||
searchScore,
|
step.context.activity['pid'],
|
||||||
null /* user.subjects */
|
text,
|
||||||
);
|
searchScore,
|
||||||
|
null /* user.subjects */
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
GBLog.error(`/answer ERROR: ${GBUtil.toYAML(error)}`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
// If there is some result, answer immediately.
|
// If there is some result, answer immediately.
|
||||||
|
|
||||||
|
|
|
@ -915,7 +915,7 @@ export class KBService implements IGBKBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return !isIgnored && currentDomain == new URL(p.href).hostname;
|
return !isIgnored && currentDomain == new URL(p.href).hostname;
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -293,8 +293,8 @@ export class GBServer {
|
||||||
if (process.env.DEV_OPEN_BROWSER) {
|
if (process.env.DEV_OPEN_BROWSER) {
|
||||||
core.openBrowserInDevelopment();
|
core.openBrowserInDevelopment();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
GBLog.error(`STOP: ${err.message ? err.message : err} ${err.stack ? err.stack : ''}`);
|
GBLog.error(`STOP: ${GBUtil.toYAML(error.message)}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
14
src/util.ts
14
src/util.ts
|
@ -106,17 +106,21 @@ export class GBUtil {
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const extractedError = extractProps(data);
|
const extractedError = extractProps(data);
|
||||||
|
let yamlString = YAML.stringify(extractedError, {
|
||||||
// Inline formatting for logs
|
|
||||||
return YAML.stringify(extractedError, {
|
|
||||||
indent: 2, // Defines the indentation
|
indent: 2, // Defines the indentation
|
||||||
flowLevel: -1, // Forces inline formatting
|
flowLevel: -1, // Forces inline formatting
|
||||||
styles: { '!!null': 'canonical' } // Optional: Customize null display
|
styles: { '!!null': 'canonical' } // Optional: Customize null display
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
|
|
||||||
|
//yamlString = yamlString.slice(0, 256); // Truncate to 1024 bytes
|
||||||
|
|
||||||
|
|
||||||
|
return yamlString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static sleep(ms) {
|
public static sleep(ms) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(resolve, ms);
|
setTimeout(resolve, ms);
|
||||||
|
|
|
@ -4,7 +4,7 @@ DESCRIPTION It is a WebService of GB.
|
||||||
products = FIND "products.csv"
|
products = FIND "products.csv"
|
||||||
|
|
||||||
BEGIN SYSTEM PROMPT
|
BEGIN SYSTEM PROMPT
|
||||||
|
|
||||||
You must act as a chatbot that will assist a store attendant by following these rules:
|
You must act as a chatbot that will assist a store attendant by following these rules:
|
||||||
Whenever the attendant places an order, it must include the table and the customer's name. Example: A 400ml Pineapple Caipirinha for Rafael at table 10.
|
Whenever the attendant places an order, it must include the table and the customer's name. Example: A 400ml Pineapple Caipirinha for Rafael at table 10.
|
||||||
Orders are based on the products and sides from this product menu:
|
Orders are based on the products and sides from this product menu:
|
||||||
|
|
16
vm-inject.js
16
vm-inject.js
|
@ -1,4 +1,7 @@
|
||||||
module.exports = (async () => {
|
module.exports = (async () => {
|
||||||
|
//##INJECTED_HEADER
|
||||||
|
|
||||||
|
|
||||||
// Imports npm packages for this .gbdialog conversational application.
|
// Imports npm packages for this .gbdialog conversational application.
|
||||||
|
|
||||||
require('isomorphic-fetch');
|
require('isomorphic-fetch');
|
||||||
|
@ -130,14 +133,15 @@ module.exports = (async () => {
|
||||||
};
|
};
|
||||||
let url;
|
let url;
|
||||||
const agent = http.Agent({ keepAlive: true });
|
const agent = http.Agent({ keepAlive: true });
|
||||||
|
|
||||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/dk';
|
|
||||||
|
url = `http://localhost:${port}/${botId}/dk`;
|
||||||
const dk = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
const dk = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
||||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/sys';
|
url = `http://localhost:${port}/${botId}/sys`;
|
||||||
const sys = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
const sys = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
||||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/wa';
|
url = `http://localhost:${port}/${botId}/wa`;
|
||||||
const wa = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
const wa = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
||||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/img';
|
url = `http://localhost:${port}/${botId}/img`;
|
||||||
const img = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
const img = (await createRpcClient(() => createHttpClient(url, { agent: agent }), optsRPC)).remote;
|
||||||
|
|
||||||
const timeout = ms => {
|
const timeout = ms => {
|
||||||
|
@ -206,7 +210,7 @@ module.exports = (async () => {
|
||||||
try {
|
try {
|
||||||
await ensureTokens(true);
|
await ensureTokens(true);
|
||||||
|
|
||||||
${code}
|
//##INJECTED_CODE_HERE
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue