andy-stack_vaultkeeper-ai/Conversations/ConversationContent.ts
Andrew Beal afdfa3021b Refactor conversation content handling and improve error messages
- Split content and functionCall into separate fields in ConversationContent
- Extract content parsing logic into dedicated methods for Claude and Gemini
- Add API error 429 handling with provider-specific user information
- Improve error messages in naming services to include response text
- Increase max_tokens for main requests and naming services
- Optimize ChatService to reduce unnecessary saves and array recreations
- Remove message key binding in ChatArea to improve performance
- Adjust chat window max-width to fixed pixel value
2025-10-20 08:30:08 +01:00

40 lines
No EOL
1.5 KiB
TypeScript

export class ConversationContent {
role: string;
content: string
functionCall: string;
timestamp: Date;
isFunctionCall: boolean;
isFunctionCallResponse: boolean;
toolId?: string;
constructor(role: string, content: string = "", functionCall: string = "", timestamp: Date = new Date(), isFunctionCall = false, isFunctionCallResponse = false, toolId?: string) {
this.role = role;
this.content = content;
this.functionCall = functionCall;
this.timestamp = timestamp;
this.isFunctionCall = isFunctionCall;
this.isFunctionCallResponse = isFunctionCallResponse;
this.toolId = toolId;
}
public static isConversationContentData(data: unknown): data is {
role: string; content: string; functionCall: string; timestamp: string, isFunctionCall: boolean, isFunctionCallResponse: boolean, toolId?: string
} {
return (
data !== null &&
typeof data === "object" &&
"role" in data &&
"content" in data &&
"functionCall" in data &&
"timestamp" in data &&
"isFunctionCall" in data &&
"isFunctionCallResponse" in data &&
typeof data.role === "string" &&
typeof data.content === "string" &&
typeof data.functionCall === "string" &&
typeof data.timestamp === "string" &&
typeof data.isFunctionCall === "boolean" &&
typeof data.isFunctionCallResponse === "boolean"
);
}
}