Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,15 +128,21 @@ class ComputerUseDemo:
|
|
| 128 |
betas=["computer-use-2024-10-22"]
|
| 129 |
)
|
| 130 |
|
| 131 |
-
#
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
# Add tool interactions to message history
|
| 137 |
messages.append({
|
| 138 |
"role": "assistant",
|
| 139 |
-
"content": [{"type": "tool_use", "name": tool_call.name, "input": tool_call.
|
| 140 |
})
|
| 141 |
messages.append({
|
| 142 |
"role": "user",
|
|
|
|
| 128 |
betas=["computer-use-2024-10-22"]
|
| 129 |
)
|
| 130 |
|
| 131 |
+
# Check for tool calls in the response
|
| 132 |
+
tool_calls = []
|
| 133 |
+
for content in response.content:
|
| 134 |
+
if hasattr(content, 'tool_calls') and content.tool_calls:
|
| 135 |
+
tool_calls.extend(content.tool_calls)
|
| 136 |
+
|
| 137 |
+
# Handle tool calls if present
|
| 138 |
+
if tool_calls:
|
| 139 |
+
tool_call = tool_calls[0] # Handle first tool call
|
| 140 |
+
tool_result = self.execute_tool(tool_call.name, tool_call.parameters)
|
| 141 |
|
| 142 |
# Add tool interactions to message history
|
| 143 |
messages.append({
|
| 144 |
"role": "assistant",
|
| 145 |
+
"content": [{"type": "tool_use", "name": tool_call.name, "input": tool_call.parameters}]
|
| 146 |
})
|
| 147 |
messages.append({
|
| 148 |
"role": "user",
|