Skip to content

Conversation

@ifirmawan
Copy link
Collaborator

@ifirmawan ifirmawan commented Dec 31, 2025

Overview

This PR implements a comprehensive language-aware AI suggestion feature that enables extension officers to communicate with farmers in their preferred language.

Implementation Details

Backend API Changes

Message Service (backend/services/message_service.py)

  • Updated message creation flow to support translation
  • Enhanced callback handlers to process translated messages

Message Router (backend/routers/messages.py)

  • Refactored message creation endpoint to handle translation scenarios
  • Improved error handling for translation failures
  • Added support for different message source types (USER, LLM, CUSTOMER)

Callback Router (backend/routers/callbacks.py)

  • Updated callback handling to support translated message processing
  • Enhanced message status tracking with translation metadata

Add new message translations endpoint and accompanying unit tests.

Summary:
- Modify  to add/adjust the message translation endpoint behavior.
- Remove the old test  and add a corrected/expanded test file .

Why:
These changes ensure AI-generated suggestions respect the farmer's main language. The new tests cover translations when the suggestion language differs from the farmer's language, preserving suggestions when languages already match, handling missing or unknown language metadata, and asserting response structure and status codes.

How to validate:
- Run  or the full test suite to verify behavior.

Refs: #95
@ifirmawan ifirmawan self-assigned this Dec 31, 2025
@ifirmawan ifirmawan linked an issue Dec 31, 2025 that may be closed by this pull request
…referred language

[#95] fix: adjust padding in chat input based on customer's language preference
@ifirmawan ifirmawan force-pushed the feature/95-ai-suggestion-respect-the-farmer-main-language branch from 5974f77 to b3473e2 Compare December 31, 2025 11:56
@ifirmawan ifirmawan changed the title Feature/95 ai suggestion respect the farmer main language Feature: AI Suggestion Respects Farmer's Main Language Dec 31, 2025
@ifirmawan ifirmawan force-pushed the feature/95-ai-suggestion-respect-the-farmer-main-language branch from cccc466 to a1f4c48 Compare January 1, 2026 02:05
refactor: remove unused translateMessage method from ApiClient
@ifirmawan ifirmawan force-pushed the feature/95-ai-suggestion-respect-the-farmer-main-language branch from 797bfc6 to 5c1c09b Compare January 1, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI Suggestion should respect the farmer main language

2 participants