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');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
count = 0;
|
||||
GBLog.error(`API Message Pooling error: ${GBUtil.toYAML(err)}`);
|
||||
GBLog.error(`API Message Pooling error: ${GBUtil.toYAML(error)}`);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -511,7 +511,9 @@ export class GBVMService extends GBService {
|
|||
|
||||
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, ' ');
|
||||
|
||||
|
|
|
@ -925,8 +925,8 @@ export class SystemKeywords {
|
|||
},
|
||||
{
|
||||
retries: 5,
|
||||
onRetry: err => {
|
||||
GBLog.error(`Retrying HTTP GET due to: ${err.message}.`);
|
||||
onRetry: error => {
|
||||
GBLog.error(`Retrying HTTP GET due to: ${error.message}.`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1842,8 +1842,8 @@ export class SystemKeywords {
|
|||
},
|
||||
{
|
||||
retries: 5,
|
||||
onRetry: err => {
|
||||
GBLog.error(`Retrying HTTP GET due to: ${err.message}.`);
|
||||
onRetry: error => {
|
||||
GBLog.error(`Retrying HTTP GET due to: ${error.message}.`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -2198,8 +2198,8 @@ export class SystemKeywords {
|
|||
},
|
||||
{
|
||||
retries: 5,
|
||||
onRetry: err => {
|
||||
GBLog.error(`MERGE: Retrying SELECT ALL on table: ${err.message}.`);
|
||||
onRetry: error => {
|
||||
GBLog.error(`MERGE: Retrying SELECT ALL on table: ${error.message}.`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -2591,8 +2591,8 @@ export class SystemKeywords {
|
|||
},
|
||||
{
|
||||
retries: 5,
|
||||
onRetry: err => {
|
||||
GBLog.error(`Retrying deleteFromStorage due to: ${err.message}.`);
|
||||
onRetry: error => {
|
||||
GBLog.error(`Retrying deleteFromStorage due to: ${error.message}.`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -2853,8 +2853,8 @@ export class SystemKeywords {
|
|||
},
|
||||
{
|
||||
retries: 5,
|
||||
onRetry: err => {
|
||||
GBLog.error(`Retrying SaveToStorage due to: ${err.message}.`);
|
||||
onRetry: error => {
|
||||
GBLog.error(`Retrying SaveToStorage due to: ${error.message}.`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -251,8 +251,8 @@ export const createVm2Pool = ({ min, max, ...limits }) => {
|
|||
await client.Runtime.enable();
|
||||
|
||||
resolve(1);
|
||||
} catch (err) {
|
||||
GBLog.error(err);
|
||||
} catch (error) {
|
||||
GBLog.error(error);
|
||||
kill(childProcess);
|
||||
GBServer.globals.debuggers[limits.botId].state = 0;
|
||||
GBServer.globals.debuggers[limits.botId].stateInfo = 'Stopped';
|
||||
|
|
|
@ -398,7 +398,7 @@ await fs.writeFile('.env', env);
|
|||
}
|
||||
try {
|
||||
instance.params = JSON.stringify(JSON.parse(instance.params));
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
instance.params = JSON.stringify(instance.params);
|
||||
}
|
||||
return await instance.save();
|
||||
|
|
|
@ -835,11 +835,11 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
try {
|
||||
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 (err.code !== 404) {
|
||||
throw err;
|
||||
if (error.code !== 404) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -847,11 +847,11 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
try {
|
||||
await search.deleteIndex();
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
// If it is a 404 there is nothing to delete as it is the first creation.
|
||||
|
||||
if (err.code !== 404 && err.code !== 'OperationNotAllowed') {
|
||||
throw err;
|
||||
if (error.code !== 404 && error.code !== 'OperationNotAllowed') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,9 +859,9 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
try {
|
||||
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString);
|
||||
} catch (err) {
|
||||
GBLog.error(err);
|
||||
throw err;
|
||||
} catch (error) {
|
||||
GBLog.error(error);
|
||||
throw error;
|
||||
}
|
||||
await search.createIndex(searchSchema, dsName);
|
||||
|
||||
|
|
|
@ -1218,6 +1218,7 @@ export class GBMinService {
|
|||
const context = adapter['createContext'](req);
|
||||
context['_activity'] = context.activity.body;
|
||||
await handler(context);
|
||||
|
||||
// Return status
|
||||
res.status(200);
|
||||
|
||||
|
@ -1230,7 +1231,7 @@ export class GBMinService {
|
|||
GBLog.error('Calling processActivity due to Signing Key could not be retrieved error.');
|
||||
await adapter['processActivity'](req, res, handler);
|
||||
} else {
|
||||
|
||||
GBLog.error(`Error processing activity: ${GBUtil.toYAML(error)}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@ -1637,7 +1638,7 @@ export class GBMinService {
|
|||
}
|
||||
});
|
||||
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', {
|
||||
data: data,
|
||||
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;
|
||||
|
||||
activity = req.body;
|
||||
|
|
|
@ -188,8 +188,8 @@ export class GoogleChatDirectLine extends GBService {
|
|||
});
|
||||
watermark = response.obj.watermark;
|
||||
await this.printMessages(response.obj.activities, conversationId, threadName, from, fromName);
|
||||
} catch (err) {
|
||||
GBLog.error(`Error calling printMessages on GoogleChat channel ${err.data === undefined ? err : err.data}`);
|
||||
} catch (error) {
|
||||
GBLog.error(`Error calling printMessages on GoogleChat channel ${GBUtil.toYAML(error)}`);
|
||||
}
|
||||
};
|
||||
setInterval(worker, this.pollInterval);
|
||||
|
|
|
@ -226,7 +226,9 @@ export class AskDialog extends IGBDialog {
|
|||
return;
|
||||
}
|
||||
|
||||
const results: any = await service.ask(
|
||||
let results;
|
||||
try {
|
||||
results = await service.ask(
|
||||
min,
|
||||
user,
|
||||
step,
|
||||
|
@ -235,6 +237,10 @@ export class AskDialog extends IGBDialog {
|
|||
searchScore,
|
||||
null /* user.subjects */
|
||||
);
|
||||
} catch (error) {
|
||||
GBLog.error(`/answer ERROR: ${GBUtil.toYAML(error)}`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
// If there is some result, answer immediately.
|
||||
|
||||
|
|
|
@ -915,7 +915,7 @@ export class KBService implements IGBKBService {
|
|||
}
|
||||
|
||||
return !isIgnored && currentDomain == new URL(p.href).hostname;
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -293,8 +293,8 @@ export class GBServer {
|
|||
if (process.env.DEV_OPEN_BROWSER) {
|
||||
core.openBrowserInDevelopment();
|
||||
}
|
||||
} catch (err) {
|
||||
GBLog.error(`STOP: ${err.message ? err.message : err} ${err.stack ? err.stack : ''}`);
|
||||
} catch (error) {
|
||||
GBLog.error(`STOP: ${GBUtil.toYAML(error.message)}`);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
|
|
10
src/util.ts
10
src/util.ts
|
@ -108,13 +108,17 @@ export class GBUtil {
|
|||
};
|
||||
|
||||
const extractedError = extractProps(data);
|
||||
|
||||
// Inline formatting for logs
|
||||
return YAML.stringify(extractedError, {
|
||||
let yamlString = YAML.stringify(extractedError, {
|
||||
indent: 2, // Defines the indentation
|
||||
flowLevel: -1, // Forces inline formatting
|
||||
styles: { '!!null': 'canonical' } // Optional: Customize null display
|
||||
} as any);
|
||||
|
||||
|
||||
//yamlString = yamlString.slice(0, 256); // Truncate to 1024 bytes
|
||||
|
||||
|
||||
return yamlString;
|
||||
}
|
||||
|
||||
public static sleep(ms) {
|
||||
|
|
14
vm-inject.js
14
vm-inject.js
|
@ -1,4 +1,7 @@
|
|||
module.exports = (async () => {
|
||||
//##INJECTED_HEADER
|
||||
|
||||
|
||||
// Imports npm packages for this .gbdialog conversational application.
|
||||
|
||||
require('isomorphic-fetch');
|
||||
|
@ -131,13 +134,14 @@ module.exports = (async () => {
|
|||
let url;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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 timeout = ms => {
|
||||
|
@ -206,7 +210,7 @@ module.exports = (async () => {
|
|||
try {
|
||||
await ensureTokens(true);
|
||||
|
||||
${code}
|
||||
//##INJECTED_CODE_HERE
|
||||
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
|
Loading…
Add table
Reference in a new issue