geoai-py 0.13.0__py2.py3-none-any.whl → 0.13.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geoai/__init__.py +1 -1
- geoai/agents/geo_agents.py +35 -20
- geoai/agents/map_tools.py +1 -1
- geoai/utils.py +15 -1
- {geoai_py-0.13.0.dist-info → geoai_py-0.13.1.dist-info}/METADATA +1 -1
- {geoai_py-0.13.0.dist-info → geoai_py-0.13.1.dist-info}/RECORD +10 -10
- {geoai_py-0.13.0.dist-info → geoai_py-0.13.1.dist-info}/WHEEL +0 -0
- {geoai_py-0.13.0.dist-info → geoai_py-0.13.1.dist-info}/entry_points.txt +0 -0
- {geoai_py-0.13.0.dist-info → geoai_py-0.13.1.dist-info}/licenses/LICENSE +0 -0
- {geoai_py-0.13.0.dist-info → geoai_py-0.13.1.dist-info}/top_level.txt +0 -0
geoai/__init__.py
CHANGED
geoai/agents/geo_agents.py
CHANGED
@@ -190,6 +190,8 @@ class GeoAgent(Agent):
|
|
190
190
|
*,
|
191
191
|
model: str = "llama3.1",
|
192
192
|
map_instance: Optional[leafmap.Map] = None,
|
193
|
+
system_prompt: str = "default",
|
194
|
+
model_args: dict = None,
|
193
195
|
**kwargs: Any,
|
194
196
|
) -> None:
|
195
197
|
"""Initialize the GeoAgent.
|
@@ -197,21 +199,25 @@ class GeoAgent(Agent):
|
|
197
199
|
Args:
|
198
200
|
model: Model identifier (default: "llama3.1").
|
199
201
|
map_instance: Optional existing map instance.
|
202
|
+
model_args: Additional keyword arguments for the model.
|
200
203
|
**kwargs: Additional keyword arguments for the model.
|
201
204
|
"""
|
202
205
|
self.session: MapSession = MapSession(map_instance)
|
203
206
|
self.tools: MapTools = MapTools(self.session)
|
204
207
|
|
208
|
+
if model_args is None:
|
209
|
+
model_args = {}
|
210
|
+
|
205
211
|
# --- save a model factory we can call each turn ---
|
206
212
|
if model == "llama3.1":
|
207
213
|
self._model_factory: Callable[[], OllamaModel] = (
|
208
214
|
lambda: create_ollama_model(
|
209
|
-
host="http://localhost:11434", model_id=model, **
|
215
|
+
host="http://localhost:11434", model_id=model, **model_args
|
210
216
|
)
|
211
217
|
)
|
212
218
|
elif isinstance(model, str):
|
213
219
|
self._model_factory: Callable[[], BedrockModel] = (
|
214
|
-
lambda: create_bedrock_model(model_id=model, **
|
220
|
+
lambda: create_bedrock_model(model_id=model, **model_args)
|
215
221
|
)
|
216
222
|
elif isinstance(model, OllamaModel):
|
217
223
|
# Extract configuration from existing OllamaModel and create new instances
|
@@ -220,7 +226,7 @@ class GeoAgent(Agent):
|
|
220
226
|
client_args = model.client_args
|
221
227
|
self._model_factory: Callable[[], OllamaModel] = (
|
222
228
|
lambda: create_ollama_model(
|
223
|
-
host=host, model_id=model_id, client_args=client_args, **
|
229
|
+
host=host, model_id=model_id, client_args=client_args, **model_args
|
224
230
|
)
|
225
231
|
)
|
226
232
|
elif isinstance(model, OpenAIModel):
|
@@ -229,7 +235,7 @@ class GeoAgent(Agent):
|
|
229
235
|
client_args = model.client_args.copy()
|
230
236
|
self._model_factory: Callable[[], OpenAIModel] = (
|
231
237
|
lambda mid=model_id, client_args=client_args: create_openai_model(
|
232
|
-
model_id=mid, client_args=client_args, **
|
238
|
+
model_id=mid, client_args=client_args, **model_args
|
233
239
|
)
|
234
240
|
)
|
235
241
|
elif isinstance(model, AnthropicModel):
|
@@ -238,7 +244,7 @@ class GeoAgent(Agent):
|
|
238
244
|
client_args = model.client_args.copy()
|
239
245
|
self._model_factory: Callable[[], AnthropicModel] = (
|
240
246
|
lambda mid=model_id, client_args=client_args: create_anthropic_model(
|
241
|
-
model_id=mid, client_args=client_args, **
|
247
|
+
model_id=mid, client_args=client_args, **model_args
|
242
248
|
)
|
243
249
|
)
|
244
250
|
else:
|
@@ -247,6 +253,28 @@ class GeoAgent(Agent):
|
|
247
253
|
# build initial model (first turn)
|
248
254
|
model = self._model_factory()
|
249
255
|
|
256
|
+
if system_prompt == "default":
|
257
|
+
system_prompt = """
|
258
|
+
You are a map control agent. Call tools with MINIMAL parameters only.
|
259
|
+
|
260
|
+
CRITICAL: Treat all kwargs parameters as optional parameters.
|
261
|
+
CRITICAL: NEVER include optional parameters unless user explicitly asks for them.
|
262
|
+
|
263
|
+
TOOL CALL RULES:
|
264
|
+
- zoom_to(zoom=N) - ONLY zoom parameter, OMIT options completely
|
265
|
+
- add_cog_layer(url='X') - NEVER include bands, nodata, opacity, etc.
|
266
|
+
- fly_to(longitude=N, latitude=N) - NEVER include zoom parameter
|
267
|
+
- add_basemap(name='X') - NEVER include any other parameters
|
268
|
+
- add_marker(lng_lat=[lon,lat]) - NEVER include popup or options
|
269
|
+
|
270
|
+
- remove_layer(name='X') - call get_layer_names() to get the layer name closest to
|
271
|
+
the name of the layer you want to remove before calling this tool
|
272
|
+
|
273
|
+
- add_overture_3d_buildings(kwargs={}) - kwargs parameter required by tool validation
|
274
|
+
FORBIDDEN: Optional parameters, string representations like '{}' or '[1,2,3]'
|
275
|
+
REQUIRED: Minimal tool calls with only what's absolutely necessary
|
276
|
+
"""
|
277
|
+
|
250
278
|
super().__init__(
|
251
279
|
name="Leafmap Visualization Agent",
|
252
280
|
model=model,
|
@@ -276,20 +304,7 @@ class GeoAgent(Agent):
|
|
276
304
|
self.tools.add_marker,
|
277
305
|
self.tools.set_pitch,
|
278
306
|
],
|
279
|
-
system_prompt=
|
280
|
-
+ "CRITICAL: Treat all kwargs parameters as optional parameters.\n"
|
281
|
-
+ "CRITICAL: NEVER include optional parameters unless user explicitly asks for them.\n\n"
|
282
|
-
+ "TOOL CALL RULES:\n"
|
283
|
-
+ "- zoom_to(zoom=N) - ONLY zoom parameter, OMIT options completely\n"
|
284
|
-
+ "- add_cog_layer(url='X') - NEVER include bands, nodata, opacity, etc.\n"
|
285
|
-
+ "- fly_to(longitude=N, latitude=N) - NEVER include zoom parameter\n"
|
286
|
-
+ "- add_basemap(name='X') - NEVER include any other parameters\n"
|
287
|
-
+ "- add_marker(lng_lat=[lon,lat]) - NEVER include popup or options\n\n"
|
288
|
-
+ "- remove_layer(name='X') - call get_layer_names() to get the layer name closest to"
|
289
|
-
+ "the name of the layer you want to remove before calling this tool\n\n"
|
290
|
-
+ "- add_overture_3d_buildings(kwargs={}) - kwargs parameter required by tool validation\n"
|
291
|
-
+ "FORBIDDEN: Optional parameters, string representations like '{}' or '[1,2,3]'\n"
|
292
|
-
+ "REQUIRED: Minimal tool calls with only what's absolutely necessary",
|
307
|
+
system_prompt=system_prompt,
|
293
308
|
callback_handler=None,
|
294
309
|
)
|
295
310
|
|
@@ -389,7 +404,7 @@ class GeoAgent(Agent):
|
|
389
404
|
),
|
390
405
|
(
|
391
406
|
"Add GeoJSON",
|
392
|
-
"Add
|
407
|
+
"Add GeoJSON layer: https://github.com/opengeos/datasets/releases/download/us/us_states.geojson",
|
393
408
|
),
|
394
409
|
("Remove layer", "Remove layer OpenTopoMap"),
|
395
410
|
("Save map", "Save the map as demo.html and return the path"),
|
geoai/agents/map_tools.py
CHANGED
@@ -115,7 +115,7 @@ class MapTools:
|
|
115
115
|
visible: bool = True,
|
116
116
|
bands: Optional[List[int]] = None,
|
117
117
|
nodata: Optional[Union[int, float]] = 0,
|
118
|
-
titiler_endpoint: str =
|
118
|
+
titiler_endpoint: str = None,
|
119
119
|
) -> str:
|
120
120
|
"""Add a Cloud Optimized GeoTIFF (COG) layer to the map.
|
121
121
|
|
geoai/utils.py
CHANGED
@@ -7522,7 +7522,11 @@ def write_colormap(
|
|
7522
7522
|
|
7523
7523
|
|
7524
7524
|
def plot_performance_metrics(
|
7525
|
-
history_path: str,
|
7525
|
+
history_path: str,
|
7526
|
+
figsize: Tuple[int, int] = (15, 5),
|
7527
|
+
verbose: bool = True,
|
7528
|
+
save_path: Optional[str] = None,
|
7529
|
+
kwargs: Optional[Dict] = None,
|
7526
7530
|
) -> None:
|
7527
7531
|
"""Plot performance metrics from a history object.
|
7528
7532
|
|
@@ -7531,6 +7535,8 @@ def plot_performance_metrics(
|
|
7531
7535
|
figsize: The figure size.
|
7532
7536
|
verbose: Whether to print the best and final metrics.
|
7533
7537
|
"""
|
7538
|
+
if kwargs is None:
|
7539
|
+
kwargs = {}
|
7534
7540
|
history = torch.load(history_path)
|
7535
7541
|
|
7536
7542
|
# Handle different key naming conventions
|
@@ -7579,6 +7585,14 @@ def plot_performance_metrics(
|
|
7579
7585
|
plt.grid(True)
|
7580
7586
|
|
7581
7587
|
plt.tight_layout()
|
7588
|
+
|
7589
|
+
if save_path:
|
7590
|
+
if "dpi" not in kwargs:
|
7591
|
+
kwargs["dpi"] = 150
|
7592
|
+
if "bbox_inches" not in kwargs:
|
7593
|
+
kwargs["bbox_inches"] = "tight"
|
7594
|
+
plt.savefig(save_path, **kwargs)
|
7595
|
+
|
7582
7596
|
plt.show()
|
7583
7597
|
|
7584
7598
|
if verbose:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
geoai/__init__.py,sha256=
|
1
|
+
geoai/__init__.py,sha256=HOXMIhkhHbKfAjjyW5KoS3iHaqq9-SUA6Vstr22G5f4,3851
|
2
2
|
geoai/change_detection.py,sha256=XkJjMEU1nD8uX3-nQy7NEmz8cukVeSaRxKJHlrv8xPM,59636
|
3
3
|
geoai/classify.py,sha256=0DcComVR6vKU4qWtH2oHVeXc7ZTcV0mFvdXRtlNmolo,35637
|
4
4
|
geoai/detectron2.py,sha256=dOOFM9M9-6PV8q2A4-mnIPrz7yTo-MpEvDiAW34nl0w,14610
|
@@ -12,13 +12,13 @@ geoai/sam.py,sha256=O6S-kGiFn7YEcFbfWFItZZQOhnsm6-GlunxQLY0daEs,34345
|
|
12
12
|
geoai/segment.py,sha256=yBGTxA-ti8lBpk7WVaBOp6yP23HkaulKJQk88acrmZ0,43788
|
13
13
|
geoai/segmentation.py,sha256=7yEzBSKCyHW1dNssoK0rdvhxi2IXsIQIFSga817KdI4,11535
|
14
14
|
geoai/train.py,sha256=r9eioaBpc2eg6hckkGVI3aGhQZffKas_UVRj-AWruu8,136049
|
15
|
-
geoai/utils.py,sha256=
|
15
|
+
geoai/utils.py,sha256=lpyhytBeDLiqWz31syeRvpbT5AUn3cOblKU57uDD9sU,301265
|
16
16
|
geoai/agents/__init__.py,sha256=NndUtQ5-i8Zuim8CJftCZYKbCvrkDXj9iLVtiBtc_qE,178
|
17
|
-
geoai/agents/geo_agents.py,sha256=
|
18
|
-
geoai/agents/map_tools.py,sha256=
|
19
|
-
geoai_py-0.13.
|
20
|
-
geoai_py-0.13.
|
21
|
-
geoai_py-0.13.
|
22
|
-
geoai_py-0.13.
|
23
|
-
geoai_py-0.13.
|
24
|
-
geoai_py-0.13.
|
17
|
+
geoai/agents/geo_agents.py,sha256=4tLntKBL_FgTQsUVzReP9acbYotnfjMRc5BYwW9WEyE,21431
|
18
|
+
geoai/agents/map_tools.py,sha256=OK5uB0VUHjjUnc-DYRy2CQ__kyUIARSCPBucGabO0Xw,60669
|
19
|
+
geoai_py-0.13.1.dist-info/licenses/LICENSE,sha256=vN2L5U7cZ6ZkOHFmc8WiGlsogWsZc5dllMeNxnKVOZg,1070
|
20
|
+
geoai_py-0.13.1.dist-info/METADATA,sha256=sNcJv-QuPoSMPAahudoWE3Z0BnV2hxwYO5bRKNKoPaA,10345
|
21
|
+
geoai_py-0.13.1.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
22
|
+
geoai_py-0.13.1.dist-info/entry_points.txt,sha256=uGp3Az3HURIsRHP9v-ys0hIbUuBBNUfXv6VbYHIXeg4,41
|
23
|
+
geoai_py-0.13.1.dist-info/top_level.txt,sha256=1YkCUWu-ii-0qIex7kbwAvfei-gos9ycyDyUCJPNWHY,6
|
24
|
+
geoai_py-0.13.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|