Repository navigation
Feature/add teacher image input - #368
Conversation
…Tanzania-AI-Community/twiga into feature/add-teacher-image-input
|
Great Job on this! I ran this branch, merged with the latest Test setup: app in Docker ( What happened on the phone
What works: all photos were transcribed accurately and rated 1. Critical issues
2. Performance & edge cases
Recommendation: request changes. Photo reading itself works well. The duplicate or wrong-photo answers and the answers that skip the textbook should be fixed before merge; both appeared within 10 minutes of real-phone testing. |
Nuh0804
left a comment
There was a problem hiding this comment.
Following up on my first review with a second round of testing: this branch merged into the latest development, vision on Together with zai-org/GLM-5.3-Flash.
Photo reading on a hosted model works well. A photo with three questions was read in 1.7 s and rated clear. The branch hasn't changed since the first review, so those points are still open. Syncing with development also needs a few changes that won't show up as conflicts.
0. Sync with development (required)
Textual conflicts in .env.template, .env.template.simple, app/assets/strings/english.yml and app/services/messaging_service.py. Beyond those:
llm_clientandagentic_modeare gone fromdevelopment. Every chat now goes throughagent_client. Remove_get_llm_client()and thellm_clientparameter of_generate_and_deliver, and callagent_clientdirectly. Keepdevelopment's_save_profile_name_replycheck at the top ofhandle_chat_message.- The prompt registry now requires
path:. Without it, the app crashes on startup withKeyError: 'path'(inline). test_image_extraction_reaches_agent_and_existing_deliverypatchesllm_settings.agentic_modeandllm_client. Remove those two patches andbasic.assert_not_awaited().english.yml: keepdevelopment's newhelptext ("change your name or your classes and subjects") and addimage_helpbelow it..envtemplates: keep bothdevelopment's model-fallback block and your vision block.
With these changes the full test suite passed for me. Heads-up: #363 (voice notes) also changes is_other_message and WhatsAppClient, so whichever lands second needs a small merge there.
1. Still open from the first review
- Photo followed by text gives two replies (critical). I didn't trigger it this round, but the code is unchanged (inline).
- Failed photos leave their placeholder in history (inline).
- Photos sent as documents get "send your question as text". Seen again this round (inline).
- Request text reads like source material. Mostly fixed by #380 in my test, since photo answers searched the textbook. Still worth rewording, now lower priority (inline).
2. Vision failures hide their cause (medium)
With a wrong model ID, every photo failed in about 0.5 s, and the only log line was Image stage=vision result=failed model=GLM-5.3-Flash. The provider's 404 is caught and dropped. Finding it meant going through config by hand (inline).
3. A bad vision URL takes the whole bot down (medium)
With IMAGE_INPUT_ENABLED=True and a local Ollama URL (http://host.docker.internal:11434/v1), the app crashed at import with VISION_BASE_URL must use HTTPS, so text chat went down too (inline).
| if not self.vision_base_url.startswith("https://"): | ||
| raise ValueError("VISION_BASE_URL must use HTTPS") |
There was a problem hiding this comment.
With local Ollama (http://host.docker.internal:11434/v1, the setup used for testing) the app now crashes at import, which takes text chat down as well. Suggest allowing plain http only for local hosts:
url = urlsplit(self.vision_base_url)
local = url.hostname in ("localhost", "127.0.0.1", "::1", "host.docker.internal")
if url.scheme != "https" and not (url.scheme == "http" and local):
raise ValueError("VISION_BASE_URL must use HTTPS unless it is local")Also consider logging the error and turning image input off instead of failing startup, so a vision misconfiguration can't stop the whole bot.
| def is_other_message(message_info: dict) -> bool: | ||
| return message_info.get("message", {}).get("type") not in ["text", "interactive"] | ||
| return message_info.get("message", {}).get("type") not in [ | ||
| "text", | ||
| "interactive", | ||
| "image", | ||
| ] |
There was a problem hiding this comment.
Still open: photos sent as documents. A JPEG sent as a file is type: document and gets "please send your question as text", which is the wrong advice. Either route document messages with an image MIME type (image/jpeg, image/png) through the image path, or change unsupported_message to suggest resending it as a photo.
| def to_request_text(self, caption: str) -> str: | ||
| return ( | ||
| "Source: teacher image\n" | ||
| f"Teacher instruction: {caption.strip() or 'none'}\n" | ||
| f"Transcription: {self.transcription.strip() or 'none'}\n" | ||
| f"Relevant visual details: {self.visual_details.strip() or 'none'}" | ||
| ) |
There was a problem hiding this comment.
Lower priority now: with #380's prompt, photo answers searched the textbook in my test. Wording this as the teacher's request instead of as a source would still make it more robust, for example:
The teacher sent a photo with this request: {caption or 'none'}
Text in the photo: ...
Visual details: ...
| image_interpreter_system: | ||
| active_version: v0.0 |
There was a problem hiding this comment.
development's prompt registry now requires a path for every entry, so the app crashes on startup with KeyError: 'path' without it:
image_interpreter_system:
path: image_interpreter_system
active_version: v0.0Keep both the model-fallback and vision blocks in the env templates, and restore the blank line black expects in logging_utils.
A text sent while a photo was being read took the agent turn first and was answered against the previous photo. The agent now accepts a `prepare` step that runs while holding the turn, so texts arriving meanwhile wait and are answered together with the interpreted photo. - A failed photo is dropped from the batch; waiting texts are still answered, after the image error is sent. - A photo arriving during another turn is read before it is buffered, so the running turn never answers it unread. - Add MessageProcessor.remove (identity match) and PreparationFailed.
A failed photo kept its "Image not yet interpreted." placeholder in the conversation, so the agent later said it still could not see the image. On any image error the row is now marked "[photo could not be read]" and left out of the agent's history; it stays in the database for audit. Generalise db.update_message_content into update_message, which updates only the given fields and keeps the owner guard and single-row check.
_cleanup_processor ran inside the locked block, so the lock was always held and no processor was ever removed: one stayed in memory per user until restart. Run the cleanup after the lock is released.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
An earlier merge of development kept this branch's older help text, so merging the PR would have reverted it in development.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
No description provided.