Added memory system
All checks were successful
Publish Library / Build NPM Project (push) Successful in 30s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2026-02-08 19:52:02 -05:00
parent d71a6be120
commit cda7db4f45
7 changed files with 163 additions and 57 deletions

View File

@@ -2,6 +2,7 @@ import * as cheerio from 'cheerio';
import {$, $Sync} from '@ztimson/node-utils';
import {ASet, consoleInterceptor, Http, fn as Fn} from '@ztimson/utils';
import {Ai} from './ai.ts';
import {LLMRequest} from './llm.ts';
export type AiToolArg = {[key: string]: {
/** Argument type */
@@ -32,7 +33,7 @@ export type AiTool = {
/** Tool arguments */
args?: AiToolArg,
/** Callback function */
fn: (args: any, ai: Ai) => any | Promise<any>,
fn: (args: any, stream: LLMRequest['stream'], ai: Ai) => any | Promise<any>,
};
export const CliTool: AiTool = {
@@ -56,15 +57,15 @@ export const ExecTool: AiTool = {
language: {type: 'string', description: 'Execution language', enum: ['cli', 'node', 'python'], required: true},
code: {type: 'string', description: 'Code to execute', required: true}
},
fn: async (args, ai) => {
fn: async (args, stream, ai) => {
try {
switch(args.type) {
case 'bash':
return await CliTool.fn({command: args.code}, ai);
return await CliTool.fn({command: args.code}, stream, ai);
case 'node':
return await JSTool.fn({code: args.code}, ai);
return await JSTool.fn({code: args.code}, stream, ai);
case 'python': {
return await PythonTool.fn({code: args.code}, ai);
return await PythonTool.fn({code: args.code}, stream, ai);
}
}
} catch(err: any) {