Added JSON / Summary LLM safeguard
This commit is contained in:
@@ -358,7 +358,7 @@ class LLM {
|
||||
* @returns {Promise<{} | {} | RegExpExecArray | null>}
|
||||
*/
|
||||
async json(text: string, schema: string, options?: LLMRequest): Promise<any> {
|
||||
let system = `Your job is to convert input to JSON. Call \`submit\` exactly once with JSON matching this schema:\n\`\`\`json\n${schema}\n\`\`\``;
|
||||
let system = `Your job is to convert input to JSON. Call the \`submit\` tool exactly once with JSON matching this schema:\n\`\`\`json\n${schema}\n\`\`\``;
|
||||
if(options?.system) system += '\n\n' + options.system;
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let done = false;
|
||||
@@ -392,7 +392,7 @@ class LLM {
|
||||
* @returns {Promise<string>} Summary
|
||||
*/
|
||||
async summarize(text: string, tokens: number = 500, options?: LLMRequest): Promise<string | null> {
|
||||
let system = `Your job is to summarize the users message. Call \`submit\` exactly once with the shortest summary possible that's <= ${tokens} tokens. Output nothing else`;
|
||||
let system = `Your job is to summarize the users message. Call the \`submit\` tool exactly once with the shortest summary possible that's <= ${tokens} tokens. Output nothing else`;
|
||||
if(options?.system) system += '\n\n' + options.system;
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let done = false;
|
||||
@@ -403,7 +403,7 @@ class LLM {
|
||||
tools: [{
|
||||
name: 'submit',
|
||||
description: 'Submit summary',
|
||||
args: {summary: {type: 'string', description: 'Summarization', required: true}},
|
||||
args: {summary: {type: 'string', description: 'Text summarization', required: true}},
|
||||
fn: (args) => {
|
||||
done = true;
|
||||
resolve(args.summary || null);
|
||||
|
||||
Reference in New Issue
Block a user