Luc Pellinger
tested ollama model locally - error due to timeout ->probably cause: insufficient local compute leading to slow Agent workflows
87ffe61 Download app.py from LucMarcelPellinger/Ollama_RAG_Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/LucMarcelPellinger/Ollama_RAG_Agent/resolve/main/app.py
- Command line
-
hf download hf://spaces/LucMarcelPellinger/Ollama_RAG_Agent/app.py
-
curl -L -o app.py https://huggingface.co/spaces/LucMarcelPellinger/Ollama_RAG_Agent/resolve/main/app.py
1.13 kB
| import gradio as gr | |
| import random | |
| from smolagents import GradioUI, CodeAgent, HfApiModel, LiteLLMModel | |
| # 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 = LiteLLMModel( | |
| model_id="ollama_chat/qwen2:7b", # Or try other Ollama-supported models | |
| api_base="http://127.0.0.1:11434", # Default Ollama local server | |
| num_ctx=8192, | |
| ) | |
| # 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() |