Spaces:
No application file
No application file
Download basic-search-agent.py from micposso/websearch-agent: direct link, hf CLI and curl.
- Browser
- Download file 766 Bytes
-
https://huggingface.co/spaces/micposso/websearch-agent/resolve/main/basic-search-agent.py
- Command line
-
hf download hf://spaces/micposso/websearch-agent/basic-search-agent.py
-
curl -L -o basic-search-agent.py https://huggingface.co/spaces/micposso/websearch-agent/resolve/main/basic-search-agent.py
766 Bytes
| from smolagents import CodeAgent, HfApiModel | |
| from smolagents import load_tool | |
| import gradio as gr | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| demo.launch() | |
| search_tool = load_tool("smol-ai/duckduckgo-search-tool", trust_remote_code=True) | |
| api_key = os.getenv("HF_TOKEN") | |
| print(api_key) | |
| from smolagents.tools import DuckDuckGoSearchTool | |
| search_tool = DuckDuckGoSearchTool() | |
| model = HfApiModel(model_id="HuggingFaceH4/zephyr-7b-beta", api_key=api_key) | |
| agent = CodeAgent( | |
| tools=[search_tool], | |
| model=model, | |
| verbose=True, | |
| max_iterations=3, | |
| max_tokens=1000, | |
| temperature=0.5, | |
| ) | |
| response = agent.run("Search the latest breakthroughs in quantum computing.") | |
| print(response) |