Better RAG memory
All checks were successful
Publish Library / Build NPM Project (push) Successful in 50s
Publish Library / Tag Version (push) Successful in 9s

This commit is contained in:
2026-02-27 12:32:27 -05:00
parent abd290246c
commit 71a7e2a904
3 changed files with 68 additions and 61 deletions

View File

@@ -11,7 +11,7 @@ export class OpenAi extends LLMProvider {
super();
this.client = new openAI(clean({
baseURL: host,
apiKey: token
apiKey: token || host ? 'ignored' : undefined
}));
}
@@ -67,7 +67,10 @@ export class OpenAi extends LLMProvider {
ask(message: string, options: LLMRequest = {}): AbortablePromise<string> {
const controller = new AbortController();
return Object.assign(new Promise<any>(async (res, rej) => {
if(options.system && options.history?.[0]?.role != 'system') options.history?.splice(0, 0, {role: 'system', content: options.system, timestamp: Date.now()});
if(options.system) {
if(options.history?.[0]?.role != 'system') options.history?.splice(0, 0, {role: 'system', content: options.system, timestamp: Date.now()});
else options.history[0].content = options.system;
}
let history = this.fromStandard([...options.history || [], {role: 'user', content: message, timestamp: Date.now()}]);
const tools = options.tools || this.ai.options.llm?.tools || [];
const requestParams: any = {