You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrate mentor notification topic extraction from gpt-4 to gpt-4.1-mini #4671
backend/utils/mentor_notifications.py:98-109 hardcodes model="gpt-4" (resolves to gpt-4-0613) for the extract_topics() function. This single call accounts for ~37% of total OpenAI spend with 0% cache hit rate and ~82K requests/30h.
The task is trivial — extract topic keywords from short conversation snippets and return a JSON array. It does not require a frontier model.
Proposed Fix
Replace the raw OpenAI client call with the shared llm_mini langchain client (gpt-4.1-mini), which is ~110x cheaper per input token for this use case.
This also brings the function in line with codebase conventions (use shared langchain clients, no in-function imports, usage tracking via _usage_callback).
Impact
~35% reduction in total OpenAI spend from a single-line model swap
Gains usage tracking via the existing _usage_callback on llm_mini
No quality regression expected — topic extraction is a simple structured-output task
Files to Change
backend/utils/mentor_notifications.py — replace client.chat.completions.create(model="gpt-4", ...) with llm_mini.invoke(...), remove raw OpenAI client init
Test Plan
Run backend/test.sh — all existing tests pass
Verify extract_topics() returns valid JSON topic arrays with gpt-4.1-mini
Monitor OpenAI dashboard post-deploy for cost drop on gpt-4-0613 line
Activity
fix: migrate mentor topic extraction from gpt-4 to gpt-4.1-mini (#4671)…
fix: migrate mentor topic extraction from gpt-4 to gpt-4.1-mini (Base…
fix: migrate mentor topic extraction from gpt-4 to gpt-4.1-mini (Base…