Spaces:
Sleeping
Sleeping
Commit ·
f1e4b62
1
Parent(s): 199576c
Update services/pipeline_executor.py
Browse files
services/pipeline_executor.py
CHANGED
|
@@ -173,8 +173,8 @@ Execute each component by calling the corresponding tool."""
|
|
| 173 |
}
|
| 174 |
|
| 175 |
for iteration in range(max_iterations):
|
| 176 |
-
# Prepare messages
|
| 177 |
-
messages = [{"role": "user", "content": user_message}]
|
| 178 |
messages.extend(conversation_history)
|
| 179 |
|
| 180 |
# Call Bedrock directly using converse API
|
|
@@ -192,8 +192,8 @@ Execute each component by calling the corresponding tool."""
|
|
| 192 |
assistant_message = response['output']['message']['content'][0]['text']
|
| 193 |
print(f"\n🤖 Mistral Response (Iteration {iteration + 1}):\n{assistant_message}\n")
|
| 194 |
|
| 195 |
-
# Add to conversation
|
| 196 |
-
conversation_history.append({"role": "assistant", "content": assistant_message})
|
| 197 |
|
| 198 |
# Check for Final Answer
|
| 199 |
if "Final Answer:" in assistant_message or "final answer" in assistant_message.lower():
|
|
@@ -261,19 +261,19 @@ Execute each component by calling the corresponding tool."""
|
|
| 261 |
"executor": "bedrock"
|
| 262 |
}
|
| 263 |
|
| 264 |
-
# Add observation to conversation
|
| 265 |
observation_message = f"Observation: {observation}"
|
| 266 |
-
conversation_history.append({"role": "user", "content": observation_message})
|
| 267 |
|
| 268 |
else:
|
| 269 |
# Unknown tool
|
| 270 |
error_msg = f"Unknown tool: {tool_name}"
|
| 271 |
-
conversation_history.append({"role": "user", "content": f"Error: {error_msg}"})
|
| 272 |
|
| 273 |
except json.JSONDecodeError as e:
|
| 274 |
# Invalid JSON
|
| 275 |
error_msg = f"Invalid JSON in Action Input: {e}"
|
| 276 |
-
conversation_history.append({"role": "user", "content": f"Error: {error_msg}"})
|
| 277 |
else:
|
| 278 |
# No action found - agent might be confused or done
|
| 279 |
if iteration > 0 and not has_called_tools:
|
|
|
|
| 173 |
}
|
| 174 |
|
| 175 |
for iteration in range(max_iterations):
|
| 176 |
+
# Prepare messages (Bedrock converse API format)
|
| 177 |
+
messages = [{"role": "user", "content": [{"text": user_message}]}]
|
| 178 |
messages.extend(conversation_history)
|
| 179 |
|
| 180 |
# Call Bedrock directly using converse API
|
|
|
|
| 192 |
assistant_message = response['output']['message']['content'][0]['text']
|
| 193 |
print(f"\n🤖 Mistral Response (Iteration {iteration + 1}):\n{assistant_message}\n")
|
| 194 |
|
| 195 |
+
# Add to conversation (Bedrock converse API format)
|
| 196 |
+
conversation_history.append({"role": "assistant", "content": [{"text": assistant_message}]})
|
| 197 |
|
| 198 |
# Check for Final Answer
|
| 199 |
if "Final Answer:" in assistant_message or "final answer" in assistant_message.lower():
|
|
|
|
| 261 |
"executor": "bedrock"
|
| 262 |
}
|
| 263 |
|
| 264 |
+
# Add observation to conversation (Bedrock converse API format)
|
| 265 |
observation_message = f"Observation: {observation}"
|
| 266 |
+
conversation_history.append({"role": "user", "content": [{"text": observation_message}]})
|
| 267 |
|
| 268 |
else:
|
| 269 |
# Unknown tool
|
| 270 |
error_msg = f"Unknown tool: {tool_name}"
|
| 271 |
+
conversation_history.append({"role": "user", "content": [{"text": f"Error: {error_msg}"}]})
|
| 272 |
|
| 273 |
except json.JSONDecodeError as e:
|
| 274 |
# Invalid JSON
|
| 275 |
error_msg = f"Invalid JSON in Action Input: {e}"
|
| 276 |
+
conversation_history.append({"role": "user", "content": [{"text": f"Error: {error_msg}"}]})
|
| 277 |
else:
|
| 278 |
# No action found - agent might be confused or done
|
| 279 |
if iteration > 0 and not has_called_tools:
|