Repository navigation
feat: conectar Langfuse al get_llm() central via LangChain CallbackHandler - #2
Merged
Merged
Conversation
…a semántica Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ciones Los resúmenes que fluyen al Company Brain de Believe (summary=overview, decision_summary=title en believe_brain.py) deben salir SIEMPRE en español, sin importar el idioma detectado de la conversación ni la preferencia del usuario. Algunos salían en inglés (ej. "Radio Segment Promotes Public Notices"). Se fuerza response_language='Spanish' en get_transcript_structure y get_reprocess_transcript_structure (conversation_processing.py) y en get_message_structure (external_integrations.py). summarize_experience_text no tenía instrucción de idioma; se le agrega respuesta en español. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…angChain Believe está instrumentando Langfuse (langfuse.believe-global.com) en todo el stack que consume LLM. omi-believe ya centraliza todos los clientes LangChain en get_llm()/clients.py con un usage_tracker propio, así que el menor esfuerzo es sumar el CallbackHandler oficial de Langfuse a la misma lista de callbacks que ya se pasa a cada cliente (OpenAI, Gemini, OpenRouter, BYOK, llm_mini) en vez de instrumentar cada call site. No-op si LANGFUSE_HOST/LANGFUSE_PUBLIC_KEY/LANGFUSE_SECRET_KEY no están en el entorno, y cualquier fallo al inicializar el handler se loguea pero no rompe el arranque. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Jbelieve
marked this pull request as ready for review
July 30, 2026 02:33
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.
Resumen
langfuse.believe-global.com) en todo el stack que consume LLM.omi-believeya centraliza todos los clientes LangChain enget_llm()(backend/utils/llm/clients.py), con unusage_tracker.pypropio + LangSmith parcial — pero 0% iba a Langfuse.CallbackHandleroficial de Langfuse (langfuse.langchain.CallbackHandler, paquetelangfuse4.14.1) a la misma lista de callbacks que ya se pasa a cada cliente LangChain (OpenAI, Gemini, OpenRouter, BYOK,llm_mini), sin duplicar el mecanismo de tracking existente.Cambios
backend/requirements.txt: agregalangfuse==4.14.1.backend/utils/llm/clients.py:_init_langfuse_callback(): crea elCallbackHandlerde Langfuse solo siLANGFUSE_HOST,LANGFUSE_PUBLIC_KEYyLANGFUSE_SECRET_KEYestán seteados en el entorno. Si falta alguno, o si la inicialización falla por cualquier motivo, devuelveNonesin romper el arranque (solo loguea)._llm_callbacks(): helper que devuelve[_usage_callback]+ el callback de Langfuse cuando está disponible — reemplaza los 5 lugares que hardcodeaban[_usage_callback]directamente (_create_byok_client,_get_or_create_openai_llm,_get_or_create_openrouter_llm,_get_or_create_gemini_llm,llm_mini).No-op garantizado
Si las 3 env vars de Langfuse no están seteadas (dev local, tests, CI), el comportamiento es idéntico al actual: solo
_usage_callback.Test plan
python3 -m py_compile backend/utils/llm/clients.py— compila sin errores.LANGFUSE_HOST/LANGFUSE_PUBLIC_KEY/LANGFUSE_SECRET_KEYen el entorno,_init_langfuse_callback()devuelveNone(no-op).langfuse.believe-global.com.🤖 Generated with Claude Code