joel memories
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import { createLogger } from "../../core/logger";
|
||||
import { OpenRouterProvider } from "./openrouter";
|
||||
import type { AiProvider, AiResponse, MessageStyle } from "./types";
|
||||
import type { ToolContext } from "./tools";
|
||||
|
||||
const logger = createLogger("AI:Service");
|
||||
|
||||
@@ -27,6 +28,23 @@ export class AiService {
|
||||
return this.provider.ask({ prompt, systemPrompt });
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a response with tool calling support
|
||||
* The AI can look up memories, save new ones, etc.
|
||||
*/
|
||||
async generateResponseWithTools(
|
||||
prompt: string,
|
||||
systemPrompt: string,
|
||||
context: ToolContext
|
||||
): Promise<AiResponse> {
|
||||
if (this.provider.askWithTools) {
|
||||
logger.debug("Generating response with tools", { promptLength: prompt.length });
|
||||
return this.provider.askWithTools({ prompt, systemPrompt, context });
|
||||
}
|
||||
// Fallback to regular response if tools not supported
|
||||
return this.generateResponse(prompt, systemPrompt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify a message to determine the appropriate response style
|
||||
*/
|
||||
@@ -37,6 +55,19 @@ export class AiService {
|
||||
// Default to snarky if provider doesn't support classification
|
||||
return "snarky";
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and save memorable information from a message
|
||||
*/
|
||||
async extractMemories(
|
||||
message: string,
|
||||
authorName: string,
|
||||
context: ToolContext
|
||||
): Promise<void> {
|
||||
if (this.provider.extractMemories) {
|
||||
return this.provider.extractMemories(message, authorName, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Singleton instance
|
||||
@@ -50,3 +81,5 @@ export function getAiService(): AiService {
|
||||
}
|
||||
|
||||
export type { AiProvider, AiResponse, MessageStyle } from "./types";
|
||||
export type { ToolContext, ToolCall, ToolResult } from "./tools";
|
||||
export { JOEL_TOOLS, MEMORY_EXTRACTION_TOOLS } from "./tools";
|
||||
|
||||
Reference in New Issue
Block a user