wip: first-chunk debug logging — paused waiting for platform-agent logs
This commit is contained in:
parent
2a23b30f83
commit
c34db0e6c0
5 changed files with 61 additions and 111 deletions
10
sdk/real.py
10
sdk/real.py
|
|
@ -4,6 +4,8 @@ import asyncio
|
|||
from collections.abc import AsyncIterator
|
||||
from pathlib import Path
|
||||
|
||||
import structlog
|
||||
|
||||
from sdk.interface import (
|
||||
Attachment,
|
||||
MessageChunk,
|
||||
|
|
@ -16,6 +18,8 @@ from sdk.interface import (
|
|||
from sdk.prototype_state import PrototypeStateStore
|
||||
from sdk.upstream_agent_api import AgentApi, MsgEventSendFile, MsgEventTextChunk
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
class RealPlatformClient(PlatformClient):
|
||||
def __init__(
|
||||
|
|
@ -157,7 +161,13 @@ class RealPlatformClient(PlatformClient):
|
|||
) -> AsyncIterator[object]:
|
||||
attachment_paths = self._attachment_paths(attachments)
|
||||
event_stream = chat_api.send_message(text, attachments=attachment_paths or None)
|
||||
chunk_index = 0
|
||||
async for event in event_stream:
|
||||
if isinstance(event, MsgEventTextChunk):
|
||||
logger.debug("agent_chunk", index=chunk_index, text=repr(event.text[:40]))
|
||||
chunk_index += 1
|
||||
else:
|
||||
logger.debug("agent_event", index=chunk_index, type=type(event).__name__)
|
||||
yield event
|
||||
|
||||
def _build_chat_api(self, chat_id: str):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue