Reviewed for LlamaIndex

This commit is contained in:
sergiopaniego
2025-03-27 13:44:43 +01:00
parent 835838d03c
commit 75d23c24cb

View File

@@ -61,6 +61,9 @@ alfred = CodeAgent(
# Import necessary libraries
from llama_index.core.agent.workflow import AgentWorkflow
from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI
from tools import search_tool, weather_info_tool, hub_stats_tool
from retriever import guest_info_tool
```
Now, let's combine all these tools into a single agent:
@@ -69,19 +72,6 @@ Now, let's combine all these tools into a single agent:
# Initialize the Hugging Face model
llm = HuggingFaceInferenceAPI(model_name="Qwen/Qwen2.5-Coder-32B-Instruct")
# Initialize the web search tool
tool_spec = DuckDuckGoSearchToolSpec()
search_tool = FunctionTool.from_defaults(tool_spec.duckduckgo_full_search)
# Initialize the weather tool
weather_info_tool = FunctionTool.from_defaults(get_weather_info)
# Initialize the Hub stats tool
hub_stats_tool = FunctionTool.from_defaults(get_hub_stats)
# Load the guest dataset and initialize the guest info tool
guest_info_tool = FunctionTool.from_defaults(get_guest_info_retriever)
# Create Alfred with all the tools
alfred = AgentWorkflow.from_tools_or_functions(
[guest_info_tool, search_tool, weather_info_tool, hub_stats_tool],