Spaces:
Running
Running
Commit
·
e7c378f
1
Parent(s):
7fc0254
updated docstrings with critical info
Browse files- api_monitor.py +20 -13
api_monitor.py
CHANGED
@@ -101,6 +101,10 @@ def validate_api_configuration(
|
|
101 |
before proceeding to activate_monitoring(). The API call may return success=True but contain
|
102 |
error messages (like "401 Unauthorized", "Invalid API key", etc.) in the sample_response.
|
103 |
|
|
|
|
|
|
|
|
|
104 |
WORKFLOW:
|
105 |
1. Call this function to validate API configuration
|
106 |
2. If success=False: Fix parameters and retry this function
|
@@ -120,7 +124,9 @@ def validate_api_configuration(
|
|
120 |
- additional_params: Optional JSON string for complex parameters
|
121 |
- schedule_interval_minutes: Minutes between calls
|
122 |
- stop_after_hours: Hours after which to stop (supports decimals, max 168 = 1 week)
|
123 |
-
- start_at: Optional datetime string for when to start the monitoring.
|
|
|
|
|
124 |
|
125 |
Input Examples:
|
126 |
|
@@ -138,18 +144,18 @@ def validate_api_configuration(
|
|
138 |
stop_after_hours: 1.5
|
139 |
start_at: ""
|
140 |
|
141 |
-
2.
|
142 |
mcp_api_key: "your_mcp_key_here"
|
143 |
-
name: "Weather
|
144 |
-
description: "Monitor
|
145 |
-
method: "
|
146 |
-
base_url: "https://api.
|
147 |
-
endpoint: "
|
148 |
-
param_keys_values: "
|
149 |
-
header_keys_values: "
|
150 |
-
additional_params:
|
151 |
-
schedule_interval_minutes:
|
152 |
-
stop_after_hours:
|
153 |
start_at: "2024-06-15 09:00:00"
|
154 |
|
155 |
Returns:
|
@@ -163,7 +169,8 @@ def validate_api_configuration(
|
|
163 |
"sample_response": {...},
|
164 |
"stop_at": "2025-06-11T12:00:00Z",
|
165 |
"start_at": "2025-06-04T12:00:00Z"
|
166 |
-
}
|
|
|
167 |
"""
|
168 |
try:
|
169 |
# Validate input parameters
|
|
|
101 |
before proceeding to activate_monitoring(). The API call may return success=True but contain
|
102 |
error messages (like "401 Unauthorized", "Invalid API key", etc.) in the sample_response.
|
103 |
|
104 |
+
CRITICAL: Always try to add parameters that will limit the API response to a manageable size.
|
105 |
+
|
106 |
+
CRITICAL: Be sure to always clearly inform the user of the config_id after a desired validation result.
|
107 |
+
|
108 |
WORKFLOW:
|
109 |
1. Call this function to validate API configuration
|
110 |
2. If success=False: Fix parameters and retry this function
|
|
|
124 |
- additional_params: Optional JSON string for complex parameters
|
125 |
- schedule_interval_minutes: Minutes between calls
|
126 |
- stop_after_hours: Hours after which to stop (supports decimals, max 168 = 1 week)
|
127 |
+
- start_at: Optional datetime string for when to start the monitoring.
|
128 |
+
|
129 |
+
IMPORTANT: Leave as empty string "" for immediate start (most common use case, always default to this if no start time provided). Only provide a datetime string (e.g., "2024-06-15 09:00:00") if you need to schedule monitoring for a specific future time.
|
130 |
|
131 |
Input Examples:
|
132 |
|
|
|
144 |
stop_after_hours: 1.5
|
145 |
start_at: ""
|
146 |
|
147 |
+
2. Weather monitoring with free API:
|
148 |
mcp_api_key: "your_mcp_key_here"
|
149 |
+
name: "Weather Monitor"
|
150 |
+
description: "Monitor current weather conditions every 2 hours for one week using Open-Meteo free API"
|
151 |
+
method: "GET"
|
152 |
+
base_url: "https://api.open-meteo.com"
|
153 |
+
endpoint: "v1/forecast"
|
154 |
+
param_keys_values: "latitude: 40.7128\nlongitude: -74.0060\ncurrent: temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m\ntimezone: America/New_York"
|
155 |
+
header_keys_values: "Content-Type: application/json"
|
156 |
+
additional_params: "{}"
|
157 |
+
schedule_interval_minutes: 120
|
158 |
+
stop_after_hours: 168
|
159 |
start_at: "2024-06-15 09:00:00"
|
160 |
|
161 |
Returns:
|
|
|
169 |
"sample_response": {...},
|
170 |
"stop_at": "2025-06-11T12:00:00Z",
|
171 |
"start_at": "2025-06-04T12:00:00Z"
|
172 |
+
}
|
173 |
+
NEXT STEP: If success=True, call activate_monitoring(config_id, mcp_api_key) to activate monitoring
|
174 |
"""
|
175 |
try:
|
176 |
# Validate input parameters
|