|
|
|
@@ -358,7 +358,7 @@ class LLM {
|
|
|
|
* @returns {Promise<{} | {} | RegExpExecArray | null>}
|
|
|
|
* @returns {Promise<{} | {} | RegExpExecArray | null>}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async json(text: string, schema: string, options?: LLMRequest): Promise<any> {
|
|
|
|
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;
|
|
|
|
if(options?.system) system += '\n\n' + options.system;
|
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
let done = false;
|
|
|
|
let done = false;
|
|
|
|
@@ -392,7 +392,7 @@ class LLM {
|
|
|
|
* @returns {Promise<string>} Summary
|
|
|
|
* @returns {Promise<string>} Summary
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
async summarize(text: string, tokens: number = 500, options?: LLMRequest): Promise<string | null> {
|
|
|
|
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;
|
|
|
|
if(options?.system) system += '\n\n' + options.system;
|
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
|
let done = false;
|
|
|
|
let done = false;
|
|
|
|
@@ -403,7 +403,7 @@ class LLM {
|
|
|
|
tools: [{
|
|
|
|
tools: [{
|
|
|
|
name: 'submit',
|
|
|
|
name: 'submit',
|
|
|
|
description: 'Submit summary',
|
|
|
|
description: 'Submit summary',
|
|
|
|
args: {summary: {type: 'string', description: 'Summarization', required: true}},
|
|
|
|
args: {summary: {type: 'string', description: 'Text summarization', required: true}},
|
|
|
|
fn: (args) => {
|
|
|
|
fn: (args) => {
|
|
|
|
done = true;
|
|
|
|
done = true;
|
|
|
|
resolve(args.summary || null);
|
|
|
|
resolve(args.summary || null);
|
|
|
|
|