Enseña tareas que ejeuta
This commit is contained in:
@@ -6,6 +6,7 @@ import html
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
from inspect import isawaitable
|
||||||
from typing import Any, Dict, List, Optional, Set
|
from typing import Any, Dict, List, Optional, Set
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@@ -197,7 +198,7 @@ class TelegramKanBot:
|
|||||||
notified_tool_calls: Set[str] = set()
|
notified_tool_calls: Set[str] = set()
|
||||||
response: Optional[RunOutput] = None
|
response: Optional[RunOutput] = None
|
||||||
try:
|
try:
|
||||||
run_result = await self.agent.arun(
|
run_result = self.agent.arun(
|
||||||
text,
|
text,
|
||||||
stream=True,
|
stream=True,
|
||||||
stream_events=True,
|
stream_events=True,
|
||||||
@@ -206,6 +207,12 @@ class TelegramKanBot:
|
|||||||
|
|
||||||
if isinstance(run_result, RunOutput):
|
if isinstance(run_result, RunOutput):
|
||||||
response = run_result
|
response = run_result
|
||||||
|
elif isawaitable(run_result):
|
||||||
|
awaited_result = await run_result
|
||||||
|
if isinstance(awaited_result, RunOutput):
|
||||||
|
response = awaited_result
|
||||||
|
else:
|
||||||
|
raise RuntimeError("El agente devolvió un resultado inesperado.")
|
||||||
else:
|
else:
|
||||||
async for event in run_result:
|
async for event in run_result:
|
||||||
if isinstance(event, RunOutput):
|
if isinstance(event, RunOutput):
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user