diff --git a/package.json b/package.json index 929a64bb..99c1ec5e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "PH ", "Dário Vieira ", "Alan Perdomo " - ], "engines": { "node": "=21.7.3" @@ -220,6 +219,7 @@ "whatsapp-web.js": "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_7", "winston": "3.8.2", "ws": "8.14.2", + "yaml": "2.4.2", "yarn": "1.22.19", "zod-to-json-schema": "^3.22.4" }, @@ -242,8 +242,8 @@ "vitest": "^1.3.0" }, "optionalDependencies": { - "@img/sharp-win32-x64": "0.33.4", - "@img/sharp-linux-arm": "0.33.4" + "@img/sharp-linux-arm": "0.33.4", + "@img/sharp-win32-x64": "0.33.4" }, "eslintConfig": { "env": { diff --git a/packages/basic.gblib/services/GBVMService.ts b/packages/basic.gblib/services/GBVMService.ts index c26475a4..a598c1a9 100644 --- a/packages/basic.gblib/services/GBVMService.ts +++ b/packages/basic.gblib/services/GBVMService.ts @@ -177,6 +177,7 @@ export class GBVMService extends GBService { "author": "${min.botId} owner.", "license": "ISC", "dependencies": { + "yaml": "2.4.2", "encoding": "0.1.13", "isomorphic-fetch": "3.0.0", "punycode": "2.1.1", @@ -510,6 +511,7 @@ export class GBVMService extends GBService { // Imports npm packages for this .gbdialog conversational application. require('isomorphic-fetch'); + const YAML = require('yaml'); const http = require('node:http'); const retry = require('async-retry'); const createRpcClient = require("@push-rpc/core").createRpcClient; @@ -649,6 +651,12 @@ export class GBVMService extends GBService { } }; + const TOYAML = (json) => { + const doc = new YAML.Document(); + doc.contents = json; + return doc.toString(); + } + // Line of Business logic. let __reportMerge = {adds: 0, updates: 0, skipped: 0}; diff --git a/packages/basic.gblib/services/SystemKeywords.ts b/packages/basic.gblib/services/SystemKeywords.ts index 2bd23c4c..2d4273eb 100644 --- a/packages/basic.gblib/services/SystemKeywords.ts +++ b/packages/basic.gblib/services/SystemKeywords.ts @@ -1331,11 +1331,12 @@ export class SystemKeywords { const xlRow = rows[foundIndex]; let hasValue = false; for (let colIndex = 0; colIndex < xlRow.length; colIndex++) { - const propertyName = header[colIndex]; + const propertyName = header[colIndex].trim(); let value = xlRow[colIndex]; if (value) { hasValue = true; + value = value.trim(); if (value.charAt(0) === "'") { if (await this.isValidDate({ pid, dt: value.substr(1) })) { value = value.substr(1); diff --git a/packages/gpt.gblib/services/ChatServices.ts b/packages/gpt.gblib/services/ChatServices.ts index b4d4a4aa..1851ed16 100644 --- a/packages/gpt.gblib/services/ChatServices.ts +++ b/packages/gpt.gblib/services/ChatServices.ts @@ -280,7 +280,7 @@ export class ChatServices { const model = new ChatOpenAI({ openAIApiKey: process.env.OPENAI_API_KEY, - modelName: 'gpt-3.5-turbo-0125', + modelName: 'gpt-4o', temperature: 0, callbacks: [logHandler] }); @@ -433,7 +433,7 @@ export class ChatServices { if (LLMMode === 'direct') { - result = directChain.invoke(question); + result = await directChain.invoke(question); } else if (LLMMode === 'document-ref' || LLMMode === 'document') { const res = await combineDocumentsChain.invoke(question); @@ -444,8 +444,14 @@ export class ChatServices { result = await conversationalToolChain.invoke({ question }); - } else if (LLMMode === 'full') { - throw new Error('Not implemented.'); // TODO: #407. + } else if (LLMMode === 'nochain') { + result = await (tools.length > 0 ? modelWithTools : model).invoke(` + ${systemPrompt} + + ${question}`); + + result = result.content; + } else { GBLogEx.info(min, `Invalid Answer Mode in Config.xlsx: ${LLMMode}.`); } diff --git a/packages/kb.gbapp/services/KBService.ts b/packages/kb.gbapp/services/KBService.ts index 510a842a..febc575a 100644 --- a/packages/kb.gbapp/services/KBService.ts +++ b/packages/kb.gbapp/services/KBService.ts @@ -911,19 +911,14 @@ export class KBService implements IGBKBService { // If the URL doesn't represent an HTML page, skip crawling its links return []; } - const currentDomain = new URL(page.url()).hostname.toLocaleLowerCase(); + const currentDomain = new URL(page.url()).hostname; let links = await page.evaluate( ({ currentDomain, websiteIgnoreUrls }) => { const anchors = Array.from(document.querySelectorAll('a')).filter(p => { try { - // Check if urlToCheck contains any of the ignored URLs - const isIgnored = websiteIgnoreUrls.split(';').some(ignoredUrl => p.href.includes(ignoredUrl)); - console.log(currentDomain); - console.log(new URL(p.href).hostname); - - return !isIgnored && currentDomain == new URL(p.href).hostname.toLocaleLowerCase(); + return currentDomain == new URL(p.href).hostname; } catch (err) { return false; } @@ -1028,7 +1023,6 @@ export class KBService implements IGBKBService { let website = min.core.getParam(min.instance, 'Website', null); const websiteIgnoreUrls = min.core.getParam(min.instance, 'Website Ignore URLs', null); - if (website) { // Removes last slash if any.