Spaces:
Running on Zero
Running on Zero
Download app.py from solnone/Unit_3_Agentic_RAG: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/solnone/Unit_3_Agentic_RAG/resolve/main/app.py
- Command line
-
hf download hf://spaces/solnone/Unit_3_Agentic_RAG/app.py
-
curl -L -o app.py https://huggingface.co/spaces/solnone/Unit_3_Agentic_RAG/resolve/main/app.py
1.16 kB
| # 兼容 ZeroGPU 啟動檢查 | |
| try: | |
| import spaces | |
| def _zero_gpu_init(): | |
| pass | |
| except ImportError: | |
| pass | |
| import gradio as gr | |
| import random | |
| from smolagents import GradioUI, CodeAgent | |
| from smolagents import InferenceClientModel | |
| # Import our custom tools from their modules | |
| from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool | |
| from retriever import load_guest_dataset | |
| # Initialize the Hugging Face model | |
| model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct") | |
| # Initialize the web search tool | |
| search_tool = DuckDuckGoSearchTool() | |
| # Initialize the weather tool | |
| weather_info_tool = WeatherInfoTool() | |
| # Initialize the Hub stats tool | |
| hub_stats_tool = HubStatsTool() | |
| # Load the guest dataset and initialize the guest info tool | |
| guest_info_tool = load_guest_dataset() | |
| # Create Alfred with all the tools | |
| alfred = CodeAgent( | |
| tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool], | |
| model=model, | |
| add_base_tools=True, # Add any additional base tools | |
| planning_interval=3 # Enable planning every 3 steps | |
| ) | |
| if __name__ == "__main__": | |
| GradioUI(alfred).launch() |