Handle multiple AI responses in one question better.
This commit is contained in:
@@ -11,6 +11,8 @@ export type LLMMessage = {
|
||||
role: 'assistant' | 'system' | 'user';
|
||||
/** Message content */
|
||||
content: string | any;
|
||||
/** Timestamp */
|
||||
timestamp: number;
|
||||
} | {
|
||||
/** Tool call */
|
||||
role: 'tool';
|
||||
@@ -24,6 +26,8 @@ export type LLMMessage = {
|
||||
content: undefined | string;
|
||||
/** Tool error */
|
||||
error: undefined | string;
|
||||
/** Timestamp */
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export type LLMOptions = {
|
||||
@@ -125,7 +129,7 @@ export class LLM {
|
||||
const recent = keep == 0 ? [] : history.slice(-keep),
|
||||
process = (keep == 0 ? history : history.slice(0, -keep)).filter(h => h.role === 'assistant' || h.role === 'user');
|
||||
const summary = await this.summarize(process.map(m => `${m.role}: ${m.content}`).join('\n\n'), 250, options);
|
||||
return [{role: 'assistant', content: `Conversation Summary: ${summary}`}, ...recent];
|
||||
return [{role: 'assistant', content: `Conversation Summary: ${summary}`, timestamp: Date.now()}, ...recent];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user