Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Merge branch 'master' of https://github.com/devbookhq/ai-api

Tomas Valenta516e13b946de
diff --cc api-service/codegen/callbacks/logs.py
index 7168dad5c,72f9af11f..83796fba6
--- a/api-service/codegen/callbacks/logs.py
+++ b/api-service/codegen/callbacks/logs.py
@@@ -81,10 -55,38 +83,11 @@@ class LogStreamParser
*self._logs_buffer,
]
- def _parse(self):
- """This function should be called only after ingesting new token or tool output to update the buffered logs."""
- thought, action_string = separate_thought_and_action(self._token_buffer)
- action_logs = [
- {"type": "tool", "name": action.attrib["tool"], "input": action.text or ""}
- for action in parse_action_string(action_string)
- ]
-
- # Update action logs with the information from ingested tools' outputs.
- for i in range(len(self._tools_output_buffer)):
- action_logs[i] = {
- **action_logs[i],
- **self._tools_output_buffer[i],
- }
-
- # We overwrite the current buffered logs with their newer version.
- # If you ingested token or tool output this will save the change so you can call self.get_logs and get the new logs.
- self._logs_buffer = [
- {
- "type": "thought",
- "content": thought.removeprefix("Thought:")
- .replace("Action:", "")
- .strip(),
- },
- *action_logs,
- ]
-
- class LogsCallbackHandler(BaseCallbackHandler):
+ class LogsCallbackHandler(AsyncCallbackHandler):
_database: Database = PrivateAttr()
_run_id: str = PrivateAttr()
+ # _loop: AbstractEventLoop = PrivateAttr()
_raw_logs: str = ""
def __init__(self, database: Database, run_id: str, **kwargs: Any):