Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,30 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from smolagents import CodeAgent, DuckDuckGoSearchTool,
|
| 4 |
|
| 5 |
-
|
|
|
|
| 6 |
|
|
|
|
| 7 |
agent = CodeAgent(
|
| 8 |
tools=[DuckDuckGoSearchTool()],
|
| 9 |
-
model=
|
| 10 |
-
model="mistralai/mistral-7b-instruct"
|
| 11 |
-
)
|
| 12 |
)
|
| 13 |
|
|
|
|
| 14 |
def who_is_bot(person_name):
|
| 15 |
-
prompt =
|
| 16 |
-
f"Who is {person_name}? "
|
| 17 |
-
"Give a short 1-2 sentence summary."
|
| 18 |
-
)
|
| 19 |
result = agent.run(prompt)
|
| 20 |
return result.strip()
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
iface.launch()
|
| 30 |
-
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
| 4 |
|
| 5 |
+
# Optional: if you add HF_TOKEN in secrets, it can use it
|
| 6 |
+
os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN")
|
| 7 |
|
| 8 |
+
# Build the agent
|
| 9 |
agent = CodeAgent(
|
| 10 |
tools=[DuckDuckGoSearchTool()],
|
| 11 |
+
model=HfApiModel(model="HuggingFaceH4/zephyr-7b-beta")
|
|
|
|
|
|
|
| 12 |
)
|
| 13 |
|
| 14 |
+
# Simple app function
|
| 15 |
def who_is_bot(person_name):
|
| 16 |
+
prompt = f"Who is {person_name}? Give a short 1-2 sentence summary."
|
|
|
|
|
|
|
|
|
|
| 17 |
result = agent.run(prompt)
|
| 18 |
return result.strip()
|
| 19 |
|
| 20 |
+
# Gradio UI
|
| 21 |
+
iface = gr.Interface(
|
| 22 |
+
fn=who_is_bot,
|
| 23 |
+
inputs=gr.Textbox(label="Person Name"),
|
| 24 |
+
outputs=gr.Textbox(label="Summary"),
|
| 25 |
+
title="Who Is Bot",
|
| 26 |
+
description="Enter a name — get a 1-2 sentence summary."
|
| 27 |
+
)
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
iface.launch()
|
|
|