Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
| 3 |
|
| 4 |
-
|
| 5 |
-
hf_token = os.getenv("HF_TOKEN")
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
prompt = (
|
| 13 |
f"Who is {person_name}? "
|
| 14 |
"Give a short 1-2 sentence summary."
|
|
@@ -16,7 +17,11 @@ def who_is_bot(person_name: str) -> str:
|
|
| 16 |
result = agent.run(prompt)
|
| 17 |
return result.strip()
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
if __name__ == "__main__":
|
| 20 |
-
|
| 21 |
-
summary = who_is_bot(person)
|
| 22 |
-
print(f"About {person}: {summary}")
|
|
|
|
| 1 |
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
| 4 |
|
| 5 |
+
os.environ["HF_TOKEN"] = os.getenv("HF_TOKEN") # from Secrets
|
|
|
|
| 6 |
|
| 7 |
+
agent = CodeAgent(
|
| 8 |
+
tools=[DuckDuckGoSearchTool()],
|
| 9 |
+
model=HfApiModel(model="HuggingFaceH4/zephyr-7b-beta")
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
def who_is_bot(person_name):
|
| 13 |
prompt = (
|
| 14 |
f"Who is {person_name}? "
|
| 15 |
"Give a short 1-2 sentence summary."
|
|
|
|
| 17 |
result = agent.run(prompt)
|
| 18 |
return result.strip()
|
| 19 |
|
| 20 |
+
iface = gr.Interface(fn=who_is_bot,
|
| 21 |
+
inputs=gr.Textbox(label="Person Name"),
|
| 22 |
+
outputs=gr.Textbox(label="Summary"),
|
| 23 |
+
title="Who Is Bot",
|
| 24 |
+
description="Enter the name of a famous person, get a 1-2 sentence summary.")
|
| 25 |
+
|
| 26 |
if __name__ == "__main__":
|
| 27 |
+
iface.launch()
|
|
|
|
|
|