Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Rename tool log fields

Tomas Valentaae3472cf2b2f
diff --git a/api-service/codegen/callbacks/log_parser.py b/api-service/codegen/callbacks/log_parser.py
index bdee4b606..38cff7923 100644
--- a/api-service/codegen/callbacks/log_parser.py
+++ b/api-service/codegen/callbacks/log_parser.py
@@ -8,8 +8,15 @@ from codegen.agent.base import parse_action_string, separate_thought_and_action
class LogStreamParser:
"""
+ We receive a stream of tokens and want to parse this stream of tokens to
+
+ // Example
+ Thought
+
+
+
To allow continuous streaming of partially finished logs we parse the logs every time we receive new token or tool output.
- We reparse only the tokens that corresponds to the buffered logs and not all the tokens that we have ever received.
+ We parse only the tokens that corresponds to the buffered logs and not all the tokens that we have ever received.
Buffered logs are partially finished logs that are either unfinished (still being streamed)
or they are tools' logs for which we haven't received outputs yet.
@@ -41,7 +48,11 @@ class LogStreamParser:
"""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)
tools_logs = [
- {"type": "tool", "name": action.attrib["tool"], "input": action.text or ""}
+ {
+ "type": "tool",
+ "tool_name": action.attrib["tool"],
+ "tool_input": action.text or "",
+ }
for action in parse_action_string(action_string)
]
@@ -101,7 +112,7 @@ class LogStreamParser:
self._tools_output_buffer.append(
{
"finish_at": str(datetime.datetime.now()),
- "output": output,
+ "tool_output": output,
}
)
self._parse()
diff --git a/components/Editor/RightSidebar/Logs/LogEntry.tsx b/components/Editor/RightSidebar/Logs/LogEntry.tsx
index 32e6805af..03d352a46 100644
--- a/components/Editor/RightSidebar/Logs/LogEntry.tsx
+++ b/components/Editor/RightSidebar/Logs/LogEntry.tsx
@@ -56,33 +56,33 @@ function LogEntry({ log }: Props) {
items-center
space-x-2
">
- {getToolIcon(log.name)}
+ {getToolIcon(log.tool_name)}
<div className="font-medium">
- {log.name}
+ {log.tool_name}
</div>
</div>
- {log.output === undefined &&
+ {log.tool_output === undefined &&
<Loader size="16px" className="text-slate-400 animate-spin" />
}
</div>
- {log.input.trim() &&
+ {log.tool_input.trim() &&
<div className="
pt-2
"
>
- {(log.name === 'RunJavaScriptCode' || log.name === 'InstallNPMDependencies') &&
+ {(log.tool_name === 'RunJavaScriptCode' || log.tool_name === 'InstallNPMDependencies') &&
<pre>
- {log.input.trim()}
+ {log.tool_input.trim()}
</pre>
}
- {log.name !== 'RunJavaScriptCode' && log.name !== 'InstallNPMDependencies' &&
+ {log.tool_name !== 'RunJavaScriptCode' && log.tool_name !== 'InstallNPMDependencies' &&
<ReactMarkdown>
- {log.input}
+ {log.tool_input}
</ReactMarkdown>
}
</div>
}
- {log.output?.trim() &&
+ {log.tool_output?.trim() &&
<div className="
border-t
mt-2
@@ -90,7 +90,7 @@ function LogEntry({ log }: Props) {
"
>
<ReactMarkdown>
- {log.output}
+ {log.tool_output}
</ReactMarkdown>
</div>
}
diff --git a/components/Editor/RightSidebar/Logs/Tools/RunCode/index.tsx b/components/Editor/RightSidebar/Logs/Tools/RunCode/index.tsx
index 49530cee1..349185888 100644
--- a/components/Editor/RightSidebar/Logs/Tools/RunCode/index.tsx
+++ b/components/Editor/RightSidebar/Logs/Tools/RunCode/index.tsx
@@ -7,7 +7,7 @@ export interface Props {
function RunCode({
log,
}: Props) {
- if (log.name !== ToolName.RunJavaScriptCode) throw new Error(`'${log.name}': This component supports only logs for 'RunJavaScriptCode' tool`)
+ if (log.tool_name !== ToolName.RunJavaScriptCode) throw new Error(`'${log.tool_name}': This component supports only logs for 'RunJavaScriptCode' tool`)
return (
diff --git a/db/types.ts b/db/types.ts
index c794aa378..9b47126b4 100644
--- a/db/types.ts
+++ b/db/types.ts
@@ -22,10 +22,10 @@ export interface ThoughtLog extends BaseLog {
export interface ToolLog extends BaseLog {
type: LogType.Tool
- name: ToolName
- input: string
+ tool_name: ToolName
+ tool_input: string
+ tool_output?: string
finish_at?: Date
- output?: string
}
export type Log = ThoughtLog | ToolLog
diff --git a/hooks/useLatestDeployment.tsx b/hooks/useLatestDeployment.tsx
index 6cc8af467..c0eb3c7e5 100644
--- a/hooks/useLatestDeployment.tsx
+++ b/hooks/useLatestDeployment.tsx
@@ -55,6 +55,7 @@ export function useLatestDeployment(project: projects, route?: Route) {
filter: `project_id=eq.${project.id}`,
}, payload => {
if (payload.new.route_id === route.id) {
+ console.log('PAYLOAD', payload)
setDeployment(payload.new as deployments)
}
})