#5 Реализовать клиентскую часть канала общения. Обновлена документация api агента
This commit is contained in:
parent
f00cf48ba2
commit
603db89c8b
1 changed files with 10 additions and 0 deletions
10
README.md
10
README.md
|
|
@ -31,6 +31,14 @@ async def main():
|
||||||
async for chunk in response:
|
async for chunk in response:
|
||||||
if isinstance(chunk, MsgEventTextChunk):
|
if isinstance(chunk, MsgEventTextChunk):
|
||||||
print(chunk.text, end="", flush=True)
|
print(chunk.text, end="", flush=True)
|
||||||
|
elif isinstance(chunk, MsgEventToolCallChunk):
|
||||||
|
print(f"Tool call started: {chunk.tool_name}")
|
||||||
|
elif isinstance(chunk, MsgEventToolResult):
|
||||||
|
print(f"Tool result: {chunk.result}")
|
||||||
|
elif isinstance(chunk, MsgEventCustomUpdate):
|
||||||
|
print(f"Progress update: {chunk.payload}")
|
||||||
|
elif isinstance(chunk, MsgEventEnd):
|
||||||
|
print(f"Generation ended, tokens used: {chunk.tokens_used}")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await api.close()
|
await api.close()
|
||||||
|
|
@ -39,6 +47,8 @@ async def main():
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> `AgentApi.send_message()` возвращает стриминг-итерируемый объект, который может выдавать не только текстовые чанки, но и события инструментов (`MsgEventToolCallChunk`, `MsgEventToolResult`, `MsgEventCustomUpdate`) и финальный `MsgEventEnd`.
|
||||||
|
|
||||||
## Предполагаемое использование
|
## Предполагаемое использование
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue