Repository navigation
fix(messages,ai-service): resolve Quick Message Sender 500 errors, lazy-load embeddings, and add runtime LLM fallback - #94
Merged
Merged
Conversation
…y-load embeddings, and add runtime LLM fallback
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
500 Internal Server Errorwhen generating networking messages in the Quick Message Sender (POST /api/messages/generate) across both Gemini and Groq providers.Root Causes Identified
connect ECONNREFUSED 127.0.0.1:8001):embed_router.pyloadedSentenceTransformer('all-MiniLM-L6-v2')synchronously at module import time, delaying Uvicorn port binding on127.0.0.1:8001by ~4 minutes on service restart whilePOST /api/settings/test-aisucceeded (since token validation calls provider APIs directly from Node.js).503 UNAVAILABLE& Missing Fallback on.invoke():gemini-3.8-flash,gemini-3.7-flash) frequently return503 UNAVAILABLEunder high demand or hold connections open without a timeout. Previously,LLMRouteronly caught errors during lazy model instantiation rather than runtime.invoke()/.with_structured_output()execution, andmessage_creator/service.pybypassed fallback routing.pdf-parsev2 API Mismatch & Prompt Vector Pollution:backend/package.jsonusespdf-parse@^2.4.5(which exports{ PDFParse }instead of a v1 function).skillsRepository.findAllandexperienceRepository.findAllProjectsreturned 384-dimembeddingfloat arrays (SELECT *), causing the 1000/2000-character truncation inmessage_creator/service.pyto be consumed by float vectors instead of user skills/projects.Changes Made
backend/ai_service/embed_router.py: Replaced import-timeSentenceTransformerloading with_LazySentenceTransformersouvicornbinds to port8001immediately on startup.backend/ai_service/router/llm_router.py&backend/ai_service/providers/gemini_provider.py:_FallbackChatModelwrapper inLLMRouter.get_model()to automatically step throughMODEL_REGISTRY[provider]["fallbacks"]on runtime503,429,404, model-unavailable, or timeout errors for both.invoke()and.with_structured_output().timeout=12toChatGoogleGenerativeAIand cappedmax_retries=1on models that have fallbacks behind them so overloaded primary models fail fast.backend/ai_service/router/rate_limiter.py: Addedsocket_connect_timeout=1andsocket_timeout=1and broadened Redis fail-open handling toredis.RedisError.backend/services/messages.service.js&backend/services/tailor.service.js:pdf-parsev2 (new PDFParse({ data }).getText()) alongside v1 function exports.embeddingvectors fromskills_poolandprojects_poolbefore sending context to the AI service.mapAiErrorforECONNREFUSED/ECONNRESET.frontend/src/pages/DashboardPage.jsx: Updated Quick Message Sender error banner to readerr.response?.data?.messagereturned by the Node backend error middleware.Test Plan
pytest backend/ai_service -v(73 passed, including newtest_runtime_fallback_on_503_unavailable)npm --prefix backend run test:unit -- tests/controllers/messages.controller.test.js(3 passed)gemini-3.8-flash->gemini-3.7-flash->gemini-3.5-flash-liteon503 UNAVAILABLE)