AgentAPI принимает base_url (по идее ws://host:port) и сам дописывает нужный эндпоинт
This commit is contained in:
parent
234050df9f
commit
c97c63b5dc
2 changed files with 3 additions and 3 deletions
|
|
@ -28,14 +28,14 @@ class AgentApi:
|
|||
def __init__(
|
||||
self,
|
||||
agent_id: str,
|
||||
url: str,
|
||||
base_url: str,
|
||||
callback: Optional[Callable[[ServerMessage], None]] = None,
|
||||
on_disconnect: Optional[Callable[['AgentApi'], None]] = None,
|
||||
chat_id: int = 0 # значение по умолчанию для обратной совместимости
|
||||
):
|
||||
self.id = agent_id # ID агента для словаря
|
||||
self.chat_id = chat_id
|
||||
self.url = urljoin(url, f"{chat_id}/")
|
||||
self.url = urljoin(base_url, f"/v1/agent_ws/{chat_id}/")
|
||||
self.callback = callback
|
||||
self.on_disconnect = on_disconnect
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from lambda_agent_api.server import MsgEventTextChunk, MsgEventToolCallChunk, Ms
|
|||
|
||||
async def main():
|
||||
chat_id = input("Chat id: ") or 0
|
||||
api = AgentApi("agent-1", "ws://localhost:8000/agent_ws/", chat_id=chat_id)
|
||||
api = AgentApi("agent-1", "ws://localhost:8000/", chat_id=chat_id)
|
||||
|
||||
try:
|
||||
await api.connect()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue