diff --git a/ai-hub/app/api/schemas.py b/ai-hub/app/api/schemas.py index 3719e34..58b1412 100644 --- a/ai-hub/app/api/schemas.py +++ b/ai-hub/app/api/schemas.py @@ -79,7 +79,7 @@ """Defines the shape of a request to the /chat endpoint.""" prompt: str = Field(..., min_length=1) # The 'model' can now be specified in the request body to switch models mid-conversation. - provider_name: Literal["deepseek", "gemini"] = Field("deepseek") + provider_name: str = Field("gemini") # Add a new optional boolean field to control the retriever load_faiss_retriever: Optional[bool] = Field(False, description="Whether to use the FAISS DB retriever for the chat.") diff --git a/ui/client-app/src/services/apiService.js b/ui/client-app/src/services/apiService.js index 8313fb6..8524cb5 100644 --- a/ui/client-app/src/services/apiService.js +++ b/ui/client-app/src/services/apiService.js @@ -311,7 +311,19 @@ body: JSON.stringify({ prompt: prompt, provider_name: providerName }), }); if (!response.ok) { - throw new Error("LLM API failed"); + let detail = "LLM API failed"; + try { + const errBody = await response.json(); + if (typeof errBody.detail === "string") { + detail = errBody.detail; + } else if (Array.isArray(errBody.detail)) { + // Pydantic 422 errors: [{"loc":..., "msg":..., "type":...}] + detail = errBody.detail.map((err) => `${err.loc.join(".")}: ${err.msg}`).join("; "); + } else if (errBody.detail) { + detail = JSON.stringify(errBody.detail); + } + } catch { } + throw new Error(detail); } const result = await response.json(); return result;