Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,45 +1,71 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
from smolagents import (
|
| 3 |
CodeAgent,
|
| 4 |
DuckDuckGoSearchTool,
|
| 5 |
-
|
| 6 |
load_tool,
|
| 7 |
-
tool
|
|
|
|
| 8 |
)
|
| 9 |
-
|
| 10 |
-
from tools.final_answer import FinalAnswerTool
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
| 13 |
# ---------------------------------------------------------
|
| 14 |
-
# 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# ---------------------------------------------------------
|
| 16 |
-
|
|
|
|
| 17 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 18 |
temperature=0.5,
|
| 19 |
)
|
| 20 |
|
| 21 |
# ---------------------------------------------------------
|
| 22 |
-
#
|
| 23 |
# ---------------------------------------------------------
|
| 24 |
-
|
| 25 |
web_search = DuckDuckGoSearchTool()
|
| 26 |
|
| 27 |
-
|
| 28 |
visit_webpage = VisitWebpageTool()
|
| 29 |
|
| 30 |
# ---------------------------------------------------------
|
| 31 |
-
#
|
| 32 |
# ---------------------------------------------------------
|
| 33 |
agent = CodeAgent(
|
| 34 |
model=model,
|
| 35 |
tools=[web_search, visit_webpage, final_answer],
|
| 36 |
max_steps=6,
|
| 37 |
verbosity_level=1,
|
|
|
|
|
|
|
| 38 |
name="Agent_GAIA_Student",
|
| 39 |
description="Agent capable of solving complex tasks using web search",
|
| 40 |
)
|
| 41 |
|
| 42 |
# ---------------------------------------------------------
|
| 43 |
-
#
|
| 44 |
# ---------------------------------------------------------
|
| 45 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import yaml
|
| 4 |
from smolagents import (
|
| 5 |
CodeAgent,
|
| 6 |
DuckDuckGoSearchTool,
|
| 7 |
+
HuggingFaceHubModel,
|
| 8 |
load_tool,
|
| 9 |
+
tool,
|
| 10 |
+
Tool
|
| 11 |
)
|
| 12 |
+
from smolagents import VisitWebpageTool
|
|
|
|
| 13 |
from Gradio_UI import GradioUI
|
| 14 |
|
| 15 |
# ---------------------------------------------------------
|
| 16 |
+
# 1. Mon outil FinalAnswerTool
|
| 17 |
+
# ---------------------------------------------------------
|
| 18 |
+
|
| 19 |
+
class FinalAnswerTool(Tool):
|
| 20 |
+
name = "final_answer"
|
| 21 |
+
description = "Provides a final answer to the given problem."
|
| 22 |
+
inputs = {
|
| 23 |
+
"answer": {
|
| 24 |
+
"type": "string",
|
| 25 |
+
"description": "The final answer to the problem",
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
output_type = "string"
|
| 29 |
+
|
| 30 |
+
def forward(self, answer: str) -> str:
|
| 31 |
+
return answer
|
| 32 |
+
|
| 33 |
+
# On instancie l'outil
|
| 34 |
+
final_answer = FinalAnswerTool()
|
| 35 |
+
|
| 36 |
+
# ---------------------------------------------------------
|
| 37 |
+
# 2. Le Cerveau LLM
|
| 38 |
# ---------------------------------------------------------
|
| 39 |
+
|
| 40 |
+
model = HuggingFaceHubModel(
|
| 41 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 42 |
temperature=0.5,
|
| 43 |
)
|
| 44 |
|
| 45 |
# ---------------------------------------------------------
|
| 46 |
+
# 3. Les Outils de mon agents
|
| 47 |
# ---------------------------------------------------------
|
| 48 |
+
# Recherche Web
|
| 49 |
web_search = DuckDuckGoSearchTool()
|
| 50 |
|
| 51 |
+
# Visite de page Web
|
| 52 |
visit_webpage = VisitWebpageTool()
|
| 53 |
|
| 54 |
# ---------------------------------------------------------
|
| 55 |
+
# 4. L'Agent
|
| 56 |
# ---------------------------------------------------------
|
| 57 |
agent = CodeAgent(
|
| 58 |
model=model,
|
| 59 |
tools=[web_search, visit_webpage, final_answer],
|
| 60 |
max_steps=6,
|
| 61 |
verbosity_level=1,
|
| 62 |
+
grammar=None,
|
| 63 |
+
planning_interval=None,
|
| 64 |
name="Agent_GAIA_Student",
|
| 65 |
description="Agent capable of solving complex tasks using web search",
|
| 66 |
)
|
| 67 |
|
| 68 |
# ---------------------------------------------------------
|
| 69 |
+
# 5. Lancement
|
| 70 |
# ---------------------------------------------------------
|
| 71 |
+
GradioUI(agent).launch()
|