mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
Add support for reading images (PNG, JPG, JPEG, WebP) and PDFs in ReadVaultFiles. Implement provider-specific formatting for binary content (Claude, OpenAI, Gemini). Update conversation structure to handle binary files separately from text responses. Add unpdf library for PDF text extraction in search.
33 lines
No EOL
1.3 KiB
TypeScript
33 lines
No EOL
1.3 KiB
TypeScript
// Platform agnostic class for function responses
|
|
|
|
import type { AIFunction } from "Enums/AIFunction";
|
|
|
|
// Used by AI providers to format function execution results for API calls
|
|
export class AIFunctionResponse {
|
|
public readonly name: AIFunction;
|
|
public readonly response: object;
|
|
public readonly toolId?: string;
|
|
|
|
public static readonly UserRejectionMessage: string = `The user has explicitly rejected this change.
|
|
They may have changed their mind about the requested change.
|
|
|
|
**CRITICAL:** Immediately stop all further actions and consult with the user`;
|
|
|
|
public static readonly UserSuggestionMessage: string = "The user has rejected the change with the following suggestion: ";
|
|
|
|
constructor(name: AIFunction, response: object, toolId?: string) {
|
|
this.name = name;
|
|
this.response = response;
|
|
this.toolId = toolId;
|
|
}
|
|
|
|
public toConversationString(): string {
|
|
return JSON.stringify({
|
|
id: this.toolId,
|
|
functionResponse: {
|
|
name: this.name,
|
|
response: { result: this.response }
|
|
}
|
|
});
|
|
}
|
|
} |