Upload folder using huggingface_hub
Browse files- src/eurus/config.py +1 -1
- src/eurus/tools/era5.py +44 -17
- web/agent_wrapper.py +1 -1
src/eurus/config.py
CHANGED
|
@@ -499,7 +499,7 @@ class AgentConfig:
|
|
| 499 |
"""Configuration for the ERA5 Agent."""
|
| 500 |
|
| 501 |
# LLM Settings
|
| 502 |
-
model_name: str = "gpt-5.
|
| 503 |
temperature: float = 0
|
| 504 |
max_tokens: int = 4096
|
| 505 |
|
|
|
|
| 499 |
"""Configuration for the ERA5 Agent."""
|
| 500 |
|
| 501 |
# LLM Settings
|
| 502 |
+
model_name: str = "gpt-5.4"
|
| 503 |
temperature: float = 0
|
| 504 |
max_tokens: int = 4096
|
| 505 |
|
src/eurus/tools/era5.py
CHANGED
|
@@ -13,7 +13,7 @@ QUERY_TYPE IS AUTO-DETECTED based on time/area rules:
|
|
| 13 |
import logging
|
| 14 |
from typing import Optional
|
| 15 |
from datetime import datetime
|
| 16 |
-
|
| 17 |
|
| 18 |
from pydantic import BaseModel, Field, field_validator
|
| 19 |
from langchain_core.tools import StructuredTool
|
|
@@ -190,26 +190,53 @@ def retrieve_era5_data(
|
|
| 190 |
# LANGCHAIN TOOL CREATION
|
| 191 |
# ============================================================================
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
def create_era5_tool(api_key: Optional[str] = None) -> StructuredTool:
|
| 194 |
-
"""Create an ERA5 tool, optionally binding a session-specific API key.
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
return StructuredTool.from_function(
|
| 200 |
func=func,
|
| 201 |
name="retrieve_era5_data",
|
| 202 |
-
description=
|
| 203 |
-
"Retrieves ERA5 climate reanalysis data from Earthmover's cloud archive.\n\n"
|
| 204 |
-
"⚠️ query_type is AUTO-DETECTED - you don't need to specify it!\n\n"
|
| 205 |
-
"Just provide:\n"
|
| 206 |
-
"- variable_id: one of 22 ERA5 variables (sst, t2, d2, skt, u10, v10, u100, v100, "
|
| 207 |
-
"sp, mslp, blh, cape, tcc, cp, lsp, tp, ssr, ssrd, tcw, tcwv, sd, stl1, swvl1)\n"
|
| 208 |
-
"- start_date, end_date: YYYY-MM-DD format\n"
|
| 209 |
-
"- lat/lon bounds: Use values from maritime route bounding box!\n\n"
|
| 210 |
-
"DATA: 1975-2024.\n"
|
| 211 |
-
"Returns file path. Load with: xr.open_zarr('PATH')"
|
| 212 |
-
),
|
| 213 |
args_schema=ERA5RetrievalArgs,
|
| 214 |
)
|
| 215 |
|
|
|
|
| 13 |
import logging
|
| 14 |
from typing import Optional
|
| 15 |
from datetime import datetime
|
| 16 |
+
|
| 17 |
|
| 18 |
from pydantic import BaseModel, Field, field_validator
|
| 19 |
from langchain_core.tools import StructuredTool
|
|
|
|
| 190 |
# LANGCHAIN TOOL CREATION
|
| 191 |
# ============================================================================
|
| 192 |
|
| 193 |
+
_ERA5_TOOL_DESCRIPTION = (
|
| 194 |
+
"Retrieves ERA5 climate reanalysis data from Earthmover's cloud archive.\n\n"
|
| 195 |
+
"⚠️ query_type is AUTO-DETECTED - you don't need to specify it!\n\n"
|
| 196 |
+
"Just provide:\n"
|
| 197 |
+
"- variable_id: one of 22 ERA5 variables (sst, t2, d2, skt, u10, v10, u100, v100, "
|
| 198 |
+
"sp, mslp, blh, cape, tcc, cp, lsp, tp, ssr, ssrd, tcw, tcwv, sd, stl1, swvl1)\n"
|
| 199 |
+
"- start_date, end_date: YYYY-MM-DD format\n"
|
| 200 |
+
"- lat/lon bounds: Use values from maritime route bounding box!\n\n"
|
| 201 |
+
"DATA: 1975-2024.\n"
|
| 202 |
+
"Returns file path. Load with: xr.open_zarr('PATH')"
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
|
| 206 |
def create_era5_tool(api_key: Optional[str] = None) -> StructuredTool:
|
| 207 |
+
"""Create an ERA5 tool, optionally binding a session-specific API key.
|
| 208 |
+
|
| 209 |
+
Uses a closure instead of functools.partial because LangGraph's ToolNode
|
| 210 |
+
calls typing.get_type_hints() which crashes on partial objects.
|
| 211 |
+
"""
|
| 212 |
+
def _bound_retrieve(
|
| 213 |
+
variable_id: str,
|
| 214 |
+
start_date: str,
|
| 215 |
+
end_date: str,
|
| 216 |
+
min_latitude: float,
|
| 217 |
+
max_latitude: float,
|
| 218 |
+
min_longitude: float,
|
| 219 |
+
max_longitude: float,
|
| 220 |
+
region: Optional[str] = None,
|
| 221 |
+
) -> str:
|
| 222 |
+
return retrieve_era5_data(
|
| 223 |
+
variable_id=variable_id,
|
| 224 |
+
start_date=start_date,
|
| 225 |
+
end_date=end_date,
|
| 226 |
+
min_latitude=min_latitude,
|
| 227 |
+
max_latitude=max_latitude,
|
| 228 |
+
min_longitude=min_longitude,
|
| 229 |
+
max_longitude=max_longitude,
|
| 230 |
+
region=region,
|
| 231 |
+
_api_key=api_key,
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
func = _bound_retrieve if api_key else retrieve_era5_data
|
| 235 |
+
|
| 236 |
return StructuredTool.from_function(
|
| 237 |
func=func,
|
| 238 |
name="retrieve_era5_data",
|
| 239 |
+
description=_ERA5_TOOL_DESCRIPTION,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
args_schema=ERA5RetrievalArgs,
|
| 241 |
)
|
| 242 |
|
web/agent_wrapper.py
CHANGED
|
@@ -41,7 +41,7 @@ class AgentSession:
|
|
| 41 |
|
| 42 |
# Available models for the selector
|
| 43 |
AVAILABLE_MODELS = [
|
| 44 |
-
{"id": "gpt-5.
|
| 45 |
{"id": "gpt-4.1", "label": "GPT-4.1", "provider": "openai"},
|
| 46 |
{"id": "o3", "label": "o3", "provider": "openai"},
|
| 47 |
{"id": "gemini-3.1-pro-preview", "label": "Gemini 3.1 Pro", "provider": "google"},
|
|
|
|
| 41 |
|
| 42 |
# Available models for the selector
|
| 43 |
AVAILABLE_MODELS = [
|
| 44 |
+
{"id": "gpt-5.4", "label": "GPT-5.4", "provider": "openai"},
|
| 45 |
{"id": "gpt-4.1", "label": "GPT-4.1", "provider": "openai"},
|
| 46 |
{"id": "o3", "label": "o3", "provider": "openai"},
|
| 47 |
{"id": "gemini-3.1-pro-preview", "label": "Gemini 3.1 Pro", "provider": "google"},
|