From 90c1e2b4611b777e423587d5f36ba126fb401bd0 Mon Sep 17 00:00:00 2001 From: "me@rodrigorodriguez.com" Date: Wed, 16 Oct 2024 12:56:09 -0300 Subject: [PATCH] new(core.gbapp): LLM alerts for data. --- packages/basic.gblib/services/SystemKeywords.ts | 2 +- packages/llm.gblib/services/ChatServices.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index d0c39e96..0b213fcc 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -750,7 +750,7 @@ export class SystemKeywords { public async saveToStorageBatch({ pid, table, rows }): Promise { const { min } = await DialogKeywords.getProcessInfo(pid); - if (typeof rows === 'object' && rows !== null) { + if (!Array.isArray(data) && typeof rows === 'object' && rows !== null) { rows = [rows]; } diff --git a/packages/llm.gblib/services/ChatServices.ts b/packages/llm.gblib/services/ChatServices.ts index 79421740..12625e94 100644 --- a/packages/llm.gblib/services/ChatServices.ts +++ b/packages/llm.gblib/services/ChatServices.ts @@ -545,12 +545,20 @@ export class ChatServices { } else if (LLMMode === 'sql' || LLMMode === 'chart') { const con = min[`llm`]['gbconnection']; const dialect = con['storageDriver']; + + const answerSource = await (min.core as any)['getParam'](min.instance, + 'Answer Source', false); let dataSource; - if (dialect === 'sqlite') { + if (dialect === 'sqlite' || answerSource === 'cache') { + + let sqliteFilePath = answerSource === 'cache' ? + path.join('work', GBUtil.getGBAIPath(min.botId), `${con['name']}.sqlite`): + con['storageFile']; + dataSource = new DataSource({ type: 'sqlite', - database: con['storageFile'], + database: sqliteFilePath, synchronize: false, logging: true });