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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user