поддержка chat_id
This commit is contained in:
parent
146dcdf21d
commit
9ac4ef1ba1
2 changed files with 7 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ import logging
|
|||
from typing import Callable, Optional, AsyncIterator
|
||||
import aiohttp
|
||||
import asyncio
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from lambda_agent_api.server import *
|
||||
from lambda_agent_api.client import *
|
||||
|
|
@ -27,10 +28,12 @@ class AgentApi:
|
|||
agent_id: str,
|
||||
url: str,
|
||||
callback: Optional[Callable[[ServerMessage], None]] = None,
|
||||
on_disconnect: Optional[Callable[['AgentApi'], None]] = None
|
||||
on_disconnect: Optional[Callable[['AgentApi'], None]] = None,
|
||||
chat_id: int = 0 # значение по умолчанию для обратной совместимости
|
||||
):
|
||||
self.id = agent_id # ID агента для словаря
|
||||
self.url = url
|
||||
self.chat_id = chat_id
|
||||
self.url = urljoin(url, f"{chat_id}/")
|
||||
self.callback = callback
|
||||
self.on_disconnect = on_disconnect
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ from lambda_agent_api.server import MsgEventTextChunk, MsgEventToolCallChunk, Ms
|
|||
|
||||
|
||||
async def main():
|
||||
api = AgentApi("agent-1", "ws://localhost:8000/agent_ws/")
|
||||
chat_id = input("Chat id: ") or 0
|
||||
api = AgentApi("agent-1", "ws://localhost:8000/agent_ws/", chat_id=chat_id)
|
||||
|
||||
await api.connect()
|
||||
while True:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue