update backend api#146
Conversation
…ructure Structure/backend api restructure
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bac1843da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const aiPersonaOptions = ["general", "learning-coach", "financial-expert", "legal-expert", "math-reasoning"] as const; | ||
| const aiModelOptions = ["gpt4", "claude", "gemini"] as const; | ||
| const aiModelOptions = ["gpt-4o", "claude-sonnet-4", "claude-opus-4.5", "gpt-5.2", "gpt-5.1", "gemini-2.5-flash", "gemini-3-flash", "gemini-3-pro"] as const; |
There was a problem hiding this comment.
Preserve legacy aiModel names for backward compatibility
The QuestionSchema now only accepts the new model names (e.g., gpt-4o, claude-sonnet-4, gemini-2.5-flash). Since /api/AIAssistant is explicitly described as a backward-compatibility endpoint, any existing clients still sending legacy values like gpt4, claude, or gemini will now fail validation and receive a 400. Consider accepting legacy names here (or mapping them server-side) so older integrations keep working.
Useful? React with 👍 / 👎.
| } else if (error) { | ||
| // Add error message to chat | ||
| const errorAiMessage: AIMessage = { | ||
| id: (Date.now() + 1).toString(), | ||
| role: "ai", |
There was a problem hiding this comment.
Show AIQuery errors when the request fails
In this flow, sendQuery returns null on failure and sets its error state asynchronously. The UI only appends an error message if error is already set in the same render pass, so a failed request often produces no visible feedback at all. Users will see their question added but get no response when the API call fails (network errors, 4xx/5xx). Consider handling the error from the sendQuery call directly or reacting to error in an effect.
Useful? React with 👍 / 👎.
update backend api structure