File size: 766 Bytes
26068d3
 
 
 
 
9dc26cb
26068d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)