fix(core.gbapp): Themes missing in PROD.
This commit is contained in:
parent
bdf5786aa5
commit
bb456cae11
3 changed files with 16 additions and 18 deletions
|
@ -712,7 +712,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
case '.gbtheme':
|
case '.gbtheme':
|
||||||
// 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(process.env.PWD, 'templates','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.verbose(min, `Theme (.gbtheme) assets accessible at: /themes/${packageName}.`);
|
GBLogEx.verbose(min, `Theme (.gbtheme) assets accessible at: /themes/${packageName}.`);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ import { SqlDatabaseChain } from 'langchain/chains/sql_db';
|
||||||
import { SqlDatabase } from 'langchain/sql_db';
|
import { SqlDatabase } from 'langchain/sql_db';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { GBMinInstance } from 'botlib';
|
import { GBMinInstance } from 'botlib';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { jsonSchemaToZod } from 'json-schema-to-zod';
|
import { jsonSchemaToZod } from 'json-schema-to-zod';
|
||||||
import { BufferWindowMemory } from 'langchain/memory';
|
import { BufferWindowMemory } from 'langchain/memory';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
@ -74,7 +74,7 @@ import {
|
||||||
import { GBUtil } from '../../../src/util.js';
|
import { GBUtil } from '../../../src/util.js';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import zodToJsonSchema from 'zod-to-json-schema';
|
import zodToJsonSchema from 'zod-to-json-schema';
|
||||||
export interface CustomOutputParserFields {}
|
export interface CustomOutputParserFields { }
|
||||||
export type ExpectedOutput = any;
|
export type ExpectedOutput = any;
|
||||||
|
|
||||||
function isChatGeneration(llmOutput: ChatGeneration | Generation): llmOutput is ChatGeneration {
|
function isChatGeneration(llmOutput: ChatGeneration | Generation): llmOutput is ChatGeneration {
|
||||||
|
@ -133,12 +133,10 @@ 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(/\\n/g, '\n');
|
|
||||||
result = result.replace(/\`\`\`/g, '');
|
|
||||||
res = JSON.parse(result);
|
res = JSON.parse(result);
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
GBLogEx.verbose(this.min, `LLM JSON error: ${GBUtil.toYAML(e)}.`);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +187,7 @@ export class ChatServices {
|
||||||
const gbaiName = GBUtil.getGBAIPath(min.botId, null);
|
const gbaiName = GBUtil.getGBAIPath(min.botId, null);
|
||||||
const localName = path.join('work', gbaiName, 'cache', `img${GBAdminService.getRndReadableIdentifier()}.png`);
|
const localName = path.join('work', gbaiName, 'cache', `img${GBAdminService.getRndReadableIdentifier()}.png`);
|
||||||
const url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName));
|
const url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', path.basename(localName));
|
||||||
await fs.writeFile(localName, buffer, { encoding: null });
|
await fs.writeFile(localName, buffer, { encoding: null });
|
||||||
return { localName: localName, url: url, data: buffer };
|
return { localName: localName, url: url, data: buffer };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,16 +221,14 @@ export class ChatServices {
|
||||||
page = await ChatServices.findPageForText(metadata.source, doc.pageContent);
|
page = await ChatServices.findPageForText(metadata.source, doc.pageContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
output = `${output}\n\n\n\nUse also the following context which is coming from Source Document: ${filename} at page: ${
|
output = `${output}\n\n\n\nUse also the following context which is coming from Source Document: ${filename} at page: ${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),
|
||||||
Ignore this block if it is an index or part of table of contents.
|
Ignore this block if it is an index or part of table of contents.
|
||||||
And memorize this block among document
|
And memorize this block among document
|
||||||
information and return when you
|
information and return when you
|
||||||
are refering this part of content:\n\n\n\n ${
|
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;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +410,7 @@ export class ChatServices {
|
||||||
Folowing answer:`)
|
Folowing answer:`)
|
||||||
] as any);
|
] as any);
|
||||||
|
|
||||||
|
|
||||||
const jsonInformation = `
|
const jsonInformation = `
|
||||||
CRITICAL INSTRUCTION: You MUST ALWAYS return ONLY a valid JSON object matching this exact structure, with no additional text before or after:
|
CRITICAL INSTRUCTION: You MUST ALWAYS return ONLY a valid JSON object matching this exact structure, with no additional text before or after:
|
||||||
|
|
||||||
|
@ -447,9 +443,10 @@ export class ChatServices {
|
||||||
- Ensure that no TOC with page numbering, indexing or summary information is included in your response.
|
- 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!
|
- You sometimes return a formatted JSON surrounded by quotes like MD, DONT RETURN LIKE THIS, just valid JSON!
|
||||||
|
- Do not use ENTER to format JSON, but keep ENTER char inside text tag.
|
||||||
|
|
||||||
Failure to follow these requirements exactly will result in an error.`;
|
Failure to follow these requirements exactly will result in an error.`;
|
||||||
|
|
||||||
|
|
||||||
const combineDocumentsPrompt = ChatPromptTemplate.fromMessages([
|
const combineDocumentsPrompt = ChatPromptTemplate.fromMessages([
|
||||||
AIMessagePromptTemplate.fromTemplate(
|
AIMessagePromptTemplate.fromTemplate(
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
Id,Name,Birthday,Email,Personalid,Address
|
Id,Name,Birthday,Email,Personalid,Address
|
||||||
|
lwkerderv,John Godf,12/12/2001,johng@fool.com.tg,12381239923,"Boulevard Street, 329"
|
|
Loading…
Add table
Reference in a new issue