Spaces:
Runtime error
Runtime error
Eddyhzd
commited on
Commit
·
ccce7c7
1
Parent(s):
9c932e5
test
Browse files- mcp_server.py +8 -2
mcp_server.py
CHANGED
|
@@ -6,8 +6,11 @@ import numpy as np
|
|
| 6 |
import plotly.express as px
|
| 7 |
from data_loader import AgriculturalDataLoader
|
| 8 |
import warnings
|
|
|
|
| 9 |
warnings.filterwarnings('ignore')
|
| 10 |
|
|
|
|
|
|
|
| 11 |
class WeedPressureAnalyzer:
|
| 12 |
"""Analyze weed pressure and recommend plots for sensitive crops."""
|
| 13 |
|
|
@@ -89,6 +92,7 @@ class WeedPressureAnalyzer:
|
|
| 89 |
# Initialize analyzer
|
| 90 |
analyzer = WeedPressureAnalyzer()
|
| 91 |
|
|
|
|
| 92 |
def analyze_herbicide_trends(years_range, plot_filter):
|
| 93 |
"""Analyze herbicide usage trends over time."""
|
| 94 |
try:
|
|
@@ -131,6 +135,7 @@ def analyze_herbicide_trends(years_range, plot_filter):
|
|
| 131 |
except Exception as e:
|
| 132 |
return None, f"Erreur: {str(e)}"
|
| 133 |
|
|
|
|
| 134 |
def predict_future_weed_pressure():
|
| 135 |
"""Predict weed pressure for the next 3 years."""
|
| 136 |
try:
|
|
@@ -165,6 +170,7 @@ def predict_future_weed_pressure():
|
|
| 165 |
except Exception as e:
|
| 166 |
return None, f"Erreur: {str(e)}"
|
| 167 |
|
|
|
|
| 168 |
def recommend_sensitive_crop_plots():
|
| 169 |
"""Recommend plots for sensitive crops."""
|
| 170 |
try:
|
|
@@ -204,6 +210,7 @@ def recommend_sensitive_crop_plots():
|
|
| 204 |
except Exception as e:
|
| 205 |
return None, f"Erreur: {str(e)}"
|
| 206 |
|
|
|
|
| 207 |
def generate_technical_alternatives(herbicide_family):
|
| 208 |
"""Generate technical alternatives."""
|
| 209 |
summary = f"""
|
|
@@ -292,5 +299,4 @@ def create_mcp_interface():
|
|
| 292 |
return demo
|
| 293 |
|
| 294 |
if __name__ == "__main__":
|
| 295 |
-
|
| 296 |
-
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
| 6 |
import plotly.express as px
|
| 7 |
from data_loader import AgriculturalDataLoader
|
| 8 |
import warnings
|
| 9 |
+
from mcp.server.fastmcp import FastMCP
|
| 10 |
warnings.filterwarnings('ignore')
|
| 11 |
|
| 12 |
+
mcp = FastMCP("mcp")
|
| 13 |
+
|
| 14 |
class WeedPressureAnalyzer:
|
| 15 |
"""Analyze weed pressure and recommend plots for sensitive crops."""
|
| 16 |
|
|
|
|
| 92 |
# Initialize analyzer
|
| 93 |
analyzer = WeedPressureAnalyzer()
|
| 94 |
|
| 95 |
+
@mcp.tool()
|
| 96 |
def analyze_herbicide_trends(years_range, plot_filter):
|
| 97 |
"""Analyze herbicide usage trends over time."""
|
| 98 |
try:
|
|
|
|
| 135 |
except Exception as e:
|
| 136 |
return None, f"Erreur: {str(e)}"
|
| 137 |
|
| 138 |
+
@mcp.tool()
|
| 139 |
def predict_future_weed_pressure():
|
| 140 |
"""Predict weed pressure for the next 3 years."""
|
| 141 |
try:
|
|
|
|
| 170 |
except Exception as e:
|
| 171 |
return None, f"Erreur: {str(e)}"
|
| 172 |
|
| 173 |
+
@mcp.tool()
|
| 174 |
def recommend_sensitive_crop_plots():
|
| 175 |
"""Recommend plots for sensitive crops."""
|
| 176 |
try:
|
|
|
|
| 210 |
except Exception as e:
|
| 211 |
return None, f"Erreur: {str(e)}"
|
| 212 |
|
| 213 |
+
@mcp.tool()
|
| 214 |
def generate_technical_alternatives(herbicide_family):
|
| 215 |
"""Generate technical alternatives."""
|
| 216 |
summary = f"""
|
|
|
|
| 299 |
return demo
|
| 300 |
|
| 301 |
if __name__ == "__main__":
|
| 302 |
+
mcp.run(transport='stdio')
|
|
|