Repository navigation
Answer in the question's language - #11
Merged
Merged
Conversation
|
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.
The first production trace in Langfuse showed an English question answered in German. This PR makes the agent answer in the language of the question. It also fixes the refusal detection, which broke as soon as answers were no longer German.
Why answers were German
detect_response_languagecounts common marker words, and a tie defaults tode. "Does my car insurance cover glass damage?" contains no English marker, so it was detected as German. The online eval and the MCP tool path use the same detector.What changed
in, are left out.generate_answeraddsAntwortsprache: <language>to the user message, on both the text path and the image path.PROMPT_VERSIONis nowinsurance-knowledge-v2.1.[[INSUFFICIENT_EVIDENCE]]for a high-risk question without evidence.[[TERM_NOT_DEFINED]]followed by one clarification question, for an undefined term.REFUSAL_TEXTSandTERM_NOT_DEFINED_TEXTSfor de, en and zh). The German refusal is unchanged.answer_reports_insufficient_evidencenow matches that fixed wording, so the evidence status no longer depends on how the model phrases a refusal.langfuse_spansfixture now resets the Langfuse clients before and after each test..envkey. With two clients in the process,get_client()disabled tracing and the tracing tests failed locally. CI has no.env, so it passed there.How the refusal problem was found
After the prompt change, all unit tests passed. A real run then showed two problems:
Neither matched the German wording that the detection looked for, so both were marked
sufficient. The eval uses the same check, so it would not have caught this either. That is why the refusal now goes through a marker.Testing
New unit and component tests for:
Antwortspracheinstruction on both paths;140 unit and component tests pass.
I ran four real questions against qwen-plus locally and checked each one:
Follow-ups (not in this PR)
langfuse._client.resource_manager, which is internal to the SDK. A Langfuse upgrade may break it. If that happens, the tracing tests fail loudly.🤖 Generated with Claude Code