smart tdee

This commit is contained in:
2026-06-16 04:38:23 +00:00
parent f2e98942ff
commit a3f01cd850
56 changed files with 2519 additions and 591 deletions
+26
View File
@@ -130,6 +130,32 @@ class HaClient:
):
yield chunk
async def send_message_with_image_stream(
self,
session_id: int,
content: str,
image_bytes: bytes,
*,
filename: str = "photo.jpg",
content_type: str = "image/jpeg",
) -> AsyncIterator[SseChunk]:
url = f"{self.base_url}/chat/sessions/{session_id}/messages"
files = {"image": (filename, image_bytes, content_type)}
data = {"content": content}
async with httpx.AsyncClient(timeout=None) as client:
async with client.stream(
"POST",
url,
headers=self._headers({"Accept": "text/event-stream"}),
files=files,
data=data,
) as response:
if response.status_code >= 400:
body = await response.aread()
raise HaApiError(body.decode("utf-8", errors="replace") or f"HTTP {response.status_code}", response.status_code)
async for chunk in iter_sse(response):
yield chunk
async def stream_generation(self, session_id: int) -> AsyncIterator[SseChunk]:
async for chunk in self._stream("GET", f"/chat/sessions/{session_id}/generation/stream"):
yield chunk