Spaces:
Sleeping
Sleeping
Commit
·
4bd31a2
0
Parent(s):
EDF Tempo Color as MCP server
Browse files- .gitattributes +35 -0
- README.md +11 -0
- app.py +59 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: EDF Tempo Color as MCP Server
|
3 |
+
emoji: 🔌
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.29.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
app.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
from datetime import datetime, timedelta
|
4 |
+
from typing import Dict
|
5 |
+
|
6 |
+
# Cache: { "YYYY-MM-DD": {...} }
|
7 |
+
color_cache: Dict[str, dict] = {}
|
8 |
+
|
9 |
+
def jour_tempo(day: str) -> dict:
|
10 |
+
"""
|
11 |
+
Fetches Tempo color data for 'today', 'tomorrow', or a specific past date.
|
12 |
+
|
13 |
+
Parameters:
|
14 |
+
day (str): 'today', 'tomorrow', or a date in 'YYYY-MM-DD' format.
|
15 |
+
|
16 |
+
Returns:
|
17 |
+
dict: JSON response from the API.
|
18 |
+
|
19 |
+
Raises:
|
20 |
+
ValueError: If the input is invalid.
|
21 |
+
requests.HTTPError: If the HTTP request fails.
|
22 |
+
"""
|
23 |
+
iso_day = formatted_day(day)
|
24 |
+
if iso_day in color_cache:
|
25 |
+
cached_data = color_cache[iso_day]
|
26 |
+
print(f"Retrieved cached data {cached_data}")
|
27 |
+
return cached_data
|
28 |
+
|
29 |
+
url = f"https://www.api-couleur-tempo.fr/api/jourTempo/{day}"
|
30 |
+
|
31 |
+
response = requests.get(url)
|
32 |
+
response.raise_for_status()
|
33 |
+
data = response.json()
|
34 |
+
color_cache[iso_day] = data
|
35 |
+
print(f"Retrieved remote data {data}")
|
36 |
+
return data
|
37 |
+
|
38 |
+
def formatted_day(day: str) -> str:
|
39 |
+
if day == "today":
|
40 |
+
return datetime.today().date().isoformat()
|
41 |
+
elif day == "tomorrow":
|
42 |
+
return (datetime.today().date() + timedelta(days=1)).isoformat()
|
43 |
+
else:
|
44 |
+
try:
|
45 |
+
datetime.strptime(day, "%Y-%m-%d")
|
46 |
+
except ValueError:
|
47 |
+
raise ValueError("Invalid date format. Use 'YYYY-MM-DD'.")
|
48 |
+
return day
|
49 |
+
|
50 |
+
demo = gr.Interface(
|
51 |
+
fn=jour_tempo,
|
52 |
+
inputs=["text"],
|
53 |
+
outputs="text",
|
54 |
+
title="Jour Tempo",
|
55 |
+
description="EDF Tempo color for 'today', 'tomorrow' or any other day (YYYY-MM-DD)."
|
56 |
+
)
|
57 |
+
|
58 |
+
if __name__ == "__main__":
|
59 |
+
demo.launch(mcp_server=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio~=5.29.0
|
2 |
+
gradio[mcp]
|
3 |
+
requests~=2.32.3
|