Skip to content

Implement language detection in the agent#3

Open
n1colasf wants to merge 1 commit intomainfrom
1-bug-assistant-responds-only-in-spanish
Open

Implement language detection in the agent#3
n1colasf wants to merge 1 commit intomainfrom
1-bug-assistant-responds-only-in-spanish

Conversation

@n1colasf
Copy link
Copy Markdown
Member

Description

Introduces a new pretool for language detection and runtime context setting to improve multilingual support and user experience. The tool detects the language of the latest user message, sets assistant context accordingly, and dynamically translates fallback messages when needed. Also includes agent configuration updates and database migration to register and integrate the tool.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Related Issues

Fixes #1

Changes Made

  • Added a new pretool LanguageAndMessageNotInfo in agents/tools.py to:
    • Detect the language of the latest user message using pycld2
    • Set runtime language context for the assistant
    • Translate the "no information" fallback message dynamically using translate
  • Integrated the new tool into CogsolFrameworkAgent by adding it to the pretools pipeline in agent.py
  • Added database migration 0004_auto_20260325_1545.py to:
    • Register the LanguageAndMessageNotInfo tool in the database
    • Update the pretools field of CogsolFrameworkAgent to include the new tool
    • Update the __code__ field of CogSolScaffoldGenerator with improved code generation logic for multiple component types
  • Ensured safe handling of translation and detection failures with fallback behavior

Testing Done

  • Tested manually:
image

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@n1colasf n1colasf linked an issue Mar 25, 2026 that may be closed by this pull request
@n1colasf n1colasf self-assigned this Mar 25, 2026
@n1colasf n1colasf added the bug Something isn't working label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Assistant responds in Spanish intermittently

1 participant