fix AgentWorkflow
Browse files
unit2/llama-index/workflows.ipynb
CHANGED
@@ -321,7 +321,9 @@
|
|
321 |
{
|
322 |
"data": {
|
323 |
"text/plain": [
|
324 |
-
"AgentOutput(response=ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, additional_kwargs={}, blocks=[TextBlock(block_type='text', text='
|
|
|
|
|
325 |
]
|
326 |
},
|
327 |
"execution_count": 33,
|
@@ -331,6 +333,7 @@
|
|
331 |
],
|
332 |
"source": [
|
333 |
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
|
|
|
334 |
"\n",
|
335 |
"# Define some tools\n",
|
336 |
"def add(a: int, b: int) -> int:\n",
|
@@ -367,7 +370,8 @@
|
|
367 |
")\n",
|
368 |
"\n",
|
369 |
"# Run the system\n",
|
370 |
-
"response = await workflow.run(user_msg=\"Can you add 5 and 3?\")"
|
|
|
371 |
]
|
372 |
}
|
373 |
],
|
|
|
321 |
{
|
322 |
"data": {
|
323 |
"text/plain": [
|
324 |
+
"AgentOutput(response=ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, additional_kwargs={}, blocks=[TextBlock(block_type='text', text='5 and 3 add up to 8.')]), tool_calls=[ToolCallResult(tool_name='handoff', tool_kwargs={'to_agent': 'add_agent', 'reason': 'The user wants to add two numbers, and the add_agent is better suited for this task.'}, tool_id='831895e7-3502-4642-92ea-8626e21ed83b', tool_output=ToolOutput(content='Agent add_agent is now handling the request due to the following reason: The user wants to add two numbers, and the add_agent is better suited for this task..\n",
|
325 |
+
"Please continue with the current request.', tool_name='handoff', raw_input={'args': (), 'kwargs': {'to_agent': 'add_agent', 'reason': 'The user wants to add two numbers, and the add_agent is better suited for this task.'}}, raw_output='Agent add_agent is now handling the request due to the following reason: The user wants to add two numbers, and the add_agent is better suited for this task..\n",
|
326 |
+
"Please continue with the current request.', is_error=False), return_direct=True), ToolCallResult(tool_name='add', tool_kwargs={'a': 5, 'b': 3}, tool_id='c29dc3f7-eaa7-4ba7-b49b-90908f860cc5', tool_output=ToolOutput(content='8', tool_name='add', raw_input={'args': (), 'kwargs': {'a': 5, 'b': 3}}, raw_output=8, is_error=False), return_direct=False)], raw=ChatCompletionStreamOutput(choices=[ChatCompletionStreamOutputChoice(delta=ChatCompletionStreamOutputDelta(role='assistant', content='.', tool_call_id=None, tool_calls=None), index=0, finish_reason=None, logprobs=None)], created=1744553546, id='', model='Qwen/Qwen2.5-Coder-32B-Instruct', system_fingerprint='3.2.1-sha-4d28897', usage=None, object='chat.completion.chunk'), current_agent_name='add_agent')"
|
327 |
]
|
328 |
},
|
329 |
"execution_count": 33,
|
|
|
333 |
],
|
334 |
"source": [
|
335 |
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
|
336 |
+
"from llama_index.core.agent.workflow import AgentWorkflow\n",
|
337 |
"\n",
|
338 |
"# Define some tools\n",
|
339 |
"def add(a: int, b: int) -> int:\n",
|
|
|
370 |
")\n",
|
371 |
"\n",
|
372 |
"# Run the system\n",
|
373 |
+
"response = await workflow.run(user_msg=\"Can you add 5 and 3?\")\n",
|
374 |
+
"response"
|
375 |
]
|
376 |
}
|
377 |
],
|