new(all): Node.js v22 and ts-node.

This commit is contained in:
me@rodrigorodriguez.com 2024-09-24 20:32:38 -03:00
parent a99430e5df
commit ad3f006eed
6 changed files with 31 additions and 12 deletions

View file

@ -802,6 +802,10 @@ await fs.writeFile('.env', env);
return new Number(value ? value : defaultValue ? defaultValue : 0).valueOf(); return new Number(value ? value : defaultValue ? defaultValue : 0).valueOf();
} }
if (typeof value === 'string') {
return value.trim();
}
const ret = value ?? defaultValue; const ret = value ?? defaultValue;
return ret; return ret;
} }

View file

@ -714,7 +714,7 @@ export class GBDeployer implements IGBDeployer {
// Updates server listeners to serve theme files in .gbtheme. // Updates server listeners to serve theme files in .gbtheme.
const filePath = path.join(GBConfigService.get('STORAGE_LIBRARY'), 'default.gbai', 'default.gbtheme'); const filePath = path.join(GBConfigService.get('STORAGE_LIBRARY'), 'default.gbai', 'default.gbtheme');
GBServer.globals.server.use('/' + urlJoin('themes', packageName), express.static( filePath)); GBServer.globals.server.use('/' + urlJoin('themes', packageName), express.static( filePath));
GBLogEx.info(min, `Theme (.gbtheme) assets accessible at: /themes/${packageName}.`); GBLogEx.verbose(min, `Theme (.gbtheme) assets accessible at: /themes/${packageName}.`);
break; break;

View file

@ -1496,7 +1496,8 @@ export class GBMinService {
); );
await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid); await GBVMService.callVM(startDialog.toLowerCase(), min, step, pid);
return;
} }
} }

View file

@ -134,8 +134,8 @@ export class GBLLMOutputParser extends BaseLLMOutputParser<ExpectedOutput> {
let res; let res;
try { try {
GBLogEx.info(this.min, result); GBLogEx.info(this.min, result);
result = result.replace(/\u000A/g, '\\n'); result = result.replace(/\u000A/g, '\n');
result = result.replace(/\\n/g, ''); result = result.replace(/\\n/g, '\n');
result = result.replace(/\`\`\`/g, ''); result = result.replace(/\`\`\`/g, '');
res = JSON.parse(result); res = JSON.parse(result);
} catch { } catch {
@ -197,7 +197,7 @@ export class ChatServices {
private static async getRelevantContext( private static async getRelevantContext(
vectorStore: HNSWLib, vectorStore: HNSWLib,
sanitizedQuestion: string, sanitizedQuestion: string,
numDocuments: number = 3 numDocuments: number = 10
): Promise<string> { ): Promise<string> {
if (sanitizedQuestion === '' || !vectorStore) { if (sanitizedQuestion === '' || !vectorStore) {
return ''; return '';
@ -227,11 +227,12 @@ export class ChatServices {
page ? page : 'entire document' page ? page : 'entire document'
} }
(you will fill the JSON sources collection field later), (you will fill the JSON sources collection field later),
never use Index or Summary pages to answer, just content. And Ignore this block if it is an index or part of table of contents.
memorize this block among document information and return when you And memorize this block among document
are refering this part of content:\n\n\n\n ${ information and return when you
are refering this part of content:\n\n\n\n ${
doc.pageContent doc.pageContent
} \n\n\n\n.`; } \n\n\n\n.`;
} }
return output; return output;
} }
@ -435,13 +436,17 @@ export class ChatServices {
Note: The example shows two source documents for illustration. You may include any number of source documents in the "sources" array as needed. Ensure each source has both "file" and "page" fields. The "page" values should refer to actual content pages, not index or summary pages. Note: The example shows two source documents for illustration. You may include any number of source documents in the "sources" array as needed. Ensure each source has both "file" and "page" fields. The "page" values should refer to actual content pages, not index or summary pages.
Requirements: Requirements:
- Do not include table of content pages in answers.
- The JSON must be valid according to RFC 8259 and parseable without errors - The JSON must be valid according to RFC 8259 and parseable without errors
- The "text" field must contain your full response - The "text" field must contain your full response
- Never say that a person needs to go a part of the document, instead look for the page content and answer the question. - Never say that a person needs to go a part of the document, instead look for the page content and answer the question.
- The "sources" array must list the source documents used, with each source having "file" and "page" fields - The "sources" array must list the source documents used, with each source having "file" and "page" fields
- Ensure the "page" numbers refer to real pages of content, not index or summary pages - Ensure the "page" numbers refer to real pages of content, not index or summary pages
- Do not include any text, markdown, or other content outside the JSON object - Do not include any text, markdown, or other content outside the JSON object
- Absolutely avoid any Table of Contents, Indexes, or Summary pages.
- Ensure that no TOC with page numbering, indexing or summary information is included in your response.
- Double check that your response contains ONLY the JSON object before returning - Double check that your response contains ONLY the JSON object before returning
- You sometimes return a formatted JSON surrounded by quotes like MD, DONT RETURN LIKE THIS, just valid JSON!
Failure to follow these requirements exactly will result in an error.`; Failure to follow these requirements exactly will result in an error.`;

12
templates/README.md Normal file
View file

@ -0,0 +1,12 @@
# General Bots Templates
| **Template** | **Title** | **Key Feature 1** | **Key Feature 2** | **Key Feature 3** |
|------------------------|-----------------------------------------|-----------------------------------------|---------------------------------------|--------------------------------------|
| **AI Search** | Comprehensive Document Search | Supports All Document Types | Displays PDF Page and AI Summary | Integration with EDM Systems |
| **Crawler** | Training LLM with Website Data | Efficient Data Extraction | Enhanced Model Accuracy | Real-Time Knowledge Updates |
| **Education** | LLM Tools for Education Systems | Streamlined Enrollment Processes | Data Management for Backend Integration | Administrative Task Automation |
| **Law** | Law Case Summaries and Interaction | Case Summarization | Document Querying | Legal Research |
| **LLM Server** | Using LLMs as REST APIs | Integrates with Legacy Applications | Easy API Generation | Streamlined Development Process |
| **LLM Tools** | Custom Integration with Data Sources | Real-Time Data Access | Custom Logic for LLM Integration | Integration with Legacy Systems |
| **Talk to Data** | SQL Interaction and Chart Generation | Natural Language Queries | Chart Generation | Business Intelligence Dashboards |

View file

@ -1,6 +1,3 @@
image = GET IMAGE "AI Search BOT and write General Bots."
SHOW IMAGE image
BEGIN SYSTEM PROMPT BEGIN SYSTEM PROMPT