Phase 17: Add image upload to chat UI
- app.py: image_input gr.Image component, respond() accepts image_path, all yields updated to 7 outputs - api_client.py: chat(image_path=None), base64-encodes image for API - services/chat.py: chat(image_path=None) passes through to api_client Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -57,11 +57,17 @@ class HTTPAPIClient:
|
||||
message: str,
|
||||
user_id: str = "default",
|
||||
show_thinking: bool = False,
|
||||
image_path: str | None = None,
|
||||
) -> AsyncIterator[tuple[str, str | None]]:
|
||||
payload: dict = {"message": message, "user_id": user_id, "show_thinking": show_thinking}
|
||||
if image_path:
|
||||
import base64
|
||||
with open(image_path, "rb") as f:
|
||||
payload["image_base64"] = base64.b64encode(f.read()).decode()
|
||||
async with self._client.stream(
|
||||
"POST",
|
||||
f"{self._url}/chat",
|
||||
json={"message": message, "user_id": user_id, "show_thinking": show_thinking},
|
||||
json=payload,
|
||||
timeout=self._timeout,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user