7f50333bdb
- 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>
31 lines
805 B
Python
31 lines
805 B
Python
from typing import AsyncIterator
|
|
|
|
from api_client import APIClientProtocol
|
|
|
|
|
|
class ChatService:
|
|
def __init__(self, api_client: APIClientProtocol):
|
|
self._api = api_client
|
|
|
|
def chat(
|
|
self,
|
|
message: str,
|
|
user_id: str,
|
|
show_thinking: bool,
|
|
image_path: str | None = None,
|
|
) -> AsyncIterator[tuple[str, str | None]]:
|
|
return self._api.chat(message, user_id, show_thinking, image_path=image_path)
|
|
|
|
async def reset(self, user_id: str) -> None:
|
|
await self._api.reset(user_id)
|
|
|
|
async def save_feedback(
|
|
self,
|
|
user_id: str,
|
|
user_msg: str,
|
|
asst_msg: str,
|
|
rating: int,
|
|
run_id: str | None,
|
|
) -> None:
|
|
await self._api.save_feedback(user_id, user_msg, asst_msg, rating, run_id)
|