Spaces:
Sleeping
Sleeping
la Meteo
Browse files
app.py
CHANGED
|
@@ -1,30 +1,25 @@
|
|
| 1 |
-
from smolagents import CodeAgent,
|
| 2 |
from tools.final_answer import FinalAnswerTool
|
| 3 |
from Gradio_UI import GradioUI
|
| 4 |
|
| 5 |
import requests
|
| 6 |
import yaml
|
| 7 |
|
|
|
|
| 8 |
# ----------------------------
|
| 9 |
# 1️⃣ OUTIL : MÉTÉO À PARIS
|
| 10 |
# ----------------------------
|
| 11 |
@tool
|
| 12 |
def get_weather_paris() -> str:
|
| 13 |
-
"""Renvoie la météo actuelle à Paris (température + description).
|
| 14 |
-
Aucun argument nécessaire.
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
try:
|
| 18 |
-
# API gratuite de Open-Meteo (pas besoin de clé)
|
| 19 |
url = "https://api.open-meteo.com/v1/forecast?latitude=48.8566&longitude=2.3522¤t_weather=true"
|
| 20 |
response = requests.get(url).json()
|
| 21 |
|
| 22 |
weather = response["current_weather"]
|
| 23 |
temperature = weather["temperature"]
|
| 24 |
-
windspeed = weather["windspeed"]
|
| 25 |
weather_code = weather["weathercode"]
|
| 26 |
|
| 27 |
-
# Description simple selon le code météo
|
| 28 |
descriptions = {
|
| 29 |
0: "ciel clair",
|
| 30 |
1: "principalement clair",
|
|
@@ -52,7 +47,7 @@ def get_weather_paris() -> str:
|
|
| 52 |
|
| 53 |
|
| 54 |
# ---------------------------------------------------
|
| 55 |
-
# 2️⃣ OUTIL : GÉNÉRATION D’IMAGE
|
| 56 |
# ---------------------------------------------------
|
| 57 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 58 |
|
|
@@ -67,10 +62,10 @@ with open("prompts.yaml", "r") as stream:
|
|
| 67 |
# -------------------------
|
| 68 |
# 4️⃣ MODÈLE UTILISÉ
|
| 69 |
# -------------------------
|
| 70 |
-
model =
|
|
|
|
| 71 |
max_tokens=2048,
|
| 72 |
temperature=0.5,
|
| 73 |
-
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 74 |
)
|
| 75 |
|
| 76 |
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, HfApiModel, load_tool, tool
|
| 2 |
from tools.final_answer import FinalAnswerTool
|
| 3 |
from Gradio_UI import GradioUI
|
| 4 |
|
| 5 |
import requests
|
| 6 |
import yaml
|
| 7 |
|
| 8 |
+
|
| 9 |
# ----------------------------
|
| 10 |
# 1️⃣ OUTIL : MÉTÉO À PARIS
|
| 11 |
# ----------------------------
|
| 12 |
@tool
|
| 13 |
def get_weather_paris() -> str:
|
| 14 |
+
"""Renvoie la météo actuelle à Paris (température + description)."""
|
|
|
|
|
|
|
|
|
|
| 15 |
try:
|
|
|
|
| 16 |
url = "https://api.open-meteo.com/v1/forecast?latitude=48.8566&longitude=2.3522¤t_weather=true"
|
| 17 |
response = requests.get(url).json()
|
| 18 |
|
| 19 |
weather = response["current_weather"]
|
| 20 |
temperature = weather["temperature"]
|
|
|
|
| 21 |
weather_code = weather["weathercode"]
|
| 22 |
|
|
|
|
| 23 |
descriptions = {
|
| 24 |
0: "ciel clair",
|
| 25 |
1: "principalement clair",
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
# ---------------------------------------------------
|
| 50 |
+
# 2️⃣ OUTIL : GÉNÉRATION D’IMAGE
|
| 51 |
# ---------------------------------------------------
|
| 52 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 53 |
|
|
|
|
| 62 |
# -------------------------
|
| 63 |
# 4️⃣ MODÈLE UTILISÉ
|
| 64 |
# -------------------------
|
| 65 |
+
model = HfApiModel(
|
| 66 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 67 |
max_tokens=2048,
|
| 68 |
temperature=0.5,
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
|