fix(tg): QA fixes — stream_message, topic_created, archive reply
- sdk/mock.py: stream_message was async def (coroutine), must be async generator with yield — caused TypeError on every user message - topic_events.py: on_topic_created now skips bot-created topics (from_user.id == bot.id); cmd_new already registers them under the correct human user_id - commands.py: cmd_archive now sends "Чат архивирован." confirmation - test_topic_events.py: add bot=SimpleNamespace(id=BOT_ID) to fixture
This commit is contained in:
parent
8901e60f6a
commit
d5ab527f5d
4 changed files with 20 additions and 13 deletions
20
sdk/mock.py
20
sdk/mock.py
|
|
@ -99,23 +99,19 @@ class MockPlatformClient:
|
|||
attachments: list[Attachment] | None = None,
|
||||
) -> AsyncIterator[MessageChunk]:
|
||||
"""
|
||||
Сейчас: один чанк с полным ответом (sync под капотом).
|
||||
При реальном SDK: заменить на SSE/WebSocket итератор в platform/mock.py.
|
||||
Сейчас: один чанк с полным ответом.
|
||||
При реальном SDK: заменить на SSE/WebSocket итератор.
|
||||
Адаптеры переписывать не нужно.
|
||||
"""
|
||||
await self._latency(200, 600)
|
||||
message_id, response, tokens = self._build_response(user_id, chat_id, text, attachments)
|
||||
logger.info("stream_message", user_id=user_id, chat_id=chat_id, message_id=message_id)
|
||||
|
||||
async def _gen() -> AsyncIterator[MessageChunk]:
|
||||
yield MessageChunk(
|
||||
message_id=message_id,
|
||||
delta=response,
|
||||
finished=True,
|
||||
tokens_used=tokens,
|
||||
)
|
||||
|
||||
return _gen()
|
||||
yield MessageChunk(
|
||||
message_id=message_id,
|
||||
delta=response,
|
||||
finished=True,
|
||||
tokens_used=tokens,
|
||||
)
|
||||
|
||||
# --------------------------------------------------------------- settings
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue