feat: replace Claude with GPT for AI chat integration

- Replace ClaudeAdapter with GPTAdapter using OpenAI GPT (gpt-5-mini)
- Implement function calling for calendar operations (getDay, proposeCreate/Update/Delete, searchEvents)
- Add provider-agnostic AI utilities in ai/utils/ (systemPrompt, toolDefinitions, toolExecutor, eventFormatter)
- Add USE_TEST_RESPONSES env var to toggle between real AI and test responses
- Switch ChatService.processMessage to use real AI provider
- Add npm run format command for Prettier
- Update CLAUDE.md with new architecture
This commit is contained in:
2026-01-10 00:22:59 +01:00
parent c897b6d680
commit 675785ec93
17 changed files with 599 additions and 61 deletions

View File

@@ -265,12 +265,26 @@ export class ChatService {
content: data.content,
});
const response = await getTestResponse(
responseIndex,
this.eventRepo,
userId,
);
responseIndex++;
let response: TestResponse;
if (process.env.USE_TEST_RESPONSES === "true") {
// Test mode: use static responses
response = await getTestResponse(responseIndex, this.eventRepo, userId);
responseIndex++;
} else {
// Production mode: use real AI
const events = await this.eventRepo.findByUserId(userId);
const history = await this.chatRepo.getMessages(conversationId, {
limit: 20,
});
response = await this.aiProvider.processMessage(data.content, {
userId,
conversationHistory: history,
existingEvents: events,
currentDate: new Date(),
});
}
// Save and then return assistant response
const answerMessage = await this.chatRepo.createMessage(conversationId, {
@@ -292,7 +306,9 @@ export class ChatService {
updates?: UpdateEventDTO,
): Promise<ChatResponse> {
// Update original message with respondedAction
await this.chatRepo.updateMessage(messageId, { respondedAction: "confirm" });
await this.chatRepo.updateMessage(messageId, {
respondedAction: "confirm",
});
// Perform the actual event operation
let content: string;