Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,14 @@ import random
|
|
| 4 |
from tools.final_answer import FinalAnswerTool
|
| 5 |
from Gradio_UI import GradioUI
|
| 6 |
|
| 7 |
-
#
|
| 8 |
@tool
|
| 9 |
-
def tell_joke(
|
| 10 |
-
"""A tool that tells a random joke.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
jokes = [
|
| 12 |
"Why don't scientists trust atoms? Because they make up everything!",
|
| 13 |
"Why was the math book sad? Because it had too many problems.",
|
|
@@ -20,18 +24,18 @@ def tell_joke(_: str = "") -> str:
|
|
| 20 |
# Final answer tool
|
| 21 |
final_answer = FinalAnswerTool()
|
| 22 |
|
| 23 |
-
#
|
| 24 |
model = HfApiModel(
|
| 25 |
max_tokens=1024,
|
| 26 |
temperature=0.7,
|
| 27 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 28 |
)
|
| 29 |
|
| 30 |
-
# Load
|
| 31 |
-
with open("prompts.yaml",
|
| 32 |
prompt_templates = yaml.safe_load(stream)
|
| 33 |
|
| 34 |
-
# Create
|
| 35 |
agent = CodeAgent(
|
| 36 |
model=model,
|
| 37 |
tools=[final_answer, tell_joke],
|
|
@@ -40,5 +44,5 @@ agent = CodeAgent(
|
|
| 40 |
prompt_templates=prompt_templates
|
| 41 |
)
|
| 42 |
|
| 43 |
-
# Launch
|
| 44 |
GradioUI(agent).launch()
|
|
|
|
| 4 |
from tools.final_answer import FinalAnswerTool
|
| 5 |
from Gradio_UI import GradioUI
|
| 6 |
|
| 7 |
+
# Tool: tell a random joke (no arguments)
|
| 8 |
@tool
|
| 9 |
+
def tell_joke() -> str:
|
| 10 |
+
"""A tool that tells a random joke.
|
| 11 |
+
|
| 12 |
+
Returns:
|
| 13 |
+
A funny one-liner from a predefined list.
|
| 14 |
+
"""
|
| 15 |
jokes = [
|
| 16 |
"Why don't scientists trust atoms? Because they make up everything!",
|
| 17 |
"Why was the math book sad? Because it had too many problems.",
|
|
|
|
| 24 |
# Final answer tool
|
| 25 |
final_answer = FinalAnswerTool()
|
| 26 |
|
| 27 |
+
# Model
|
| 28 |
model = HfApiModel(
|
| 29 |
max_tokens=1024,
|
| 30 |
temperature=0.7,
|
| 31 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 32 |
)
|
| 33 |
|
| 34 |
+
# Load system prompt
|
| 35 |
+
with open("prompts.yaml", 'r') as stream:
|
| 36 |
prompt_templates = yaml.safe_load(stream)
|
| 37 |
|
| 38 |
+
# Create agent
|
| 39 |
agent = CodeAgent(
|
| 40 |
model=model,
|
| 41 |
tools=[final_answer, tell_joke],
|
|
|
|
| 44 |
prompt_templates=prompt_templates
|
| 45 |
)
|
| 46 |
|
| 47 |
+
# Launch UI
|
| 48 |
GradioUI(agent).launch()
|