Skip to content

Commit

Permalink
new(all): Auto import for logo, colors and website content.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Rodriguez committed May 24, 2024
1 parent 69ae924 commit 4335dfc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"PH <[email protected]>",
"Dário Vieira <[email protected]>",
"Alan Perdomo <[email protected]>"

],
"engines": {
"node": "=21.7.3"
Expand Down Expand Up @@ -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"
},
Expand All @@ -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": {
Expand Down
8 changes: 8 additions & 0 deletions packages/basic.gblib/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion packages/basic.gblib/services/SystemKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 10 additions & 4 deletions packages/gpt.gblib/services/ChatServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
});
Expand Down Expand Up @@ -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);
Expand All @@ -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}.`);
}
Expand Down
10 changes: 2 additions & 8 deletions packages/kb.gbapp/services/KBService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1028,7 +1023,6 @@ export class KBService implements IGBKBService {
let website = min.core.getParam<string>(min.instance, 'Website', null);
const websiteIgnoreUrls = min.core.getParam<string>(min.instance, 'Website Ignore URLs', null);

if (website) {

// Removes last slash if any.

Expand Down

0 comments on commit 4335dfc

Please sign in to comment.