pycityagent 2.0.0a31__py3-none-any.whl → 2.0.0a33__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.
@@ -9,6 +9,7 @@ from typing import Any
9
9
  from uuid import UUID
10
10
 
11
11
  import fastavro
12
+ import pyproj
12
13
  import ray
13
14
  from langchain_core.embeddings import Embeddings
14
15
 
@@ -80,6 +81,7 @@ class AgentGroup:
80
81
  # Step:2 prepare Simulator
81
82
  logger.info(f"-----Creating Simulator in AgentGroup {self._uuid} ...")
82
83
  self.simulator = Simulator(config["simulator_request"])
84
+ self.projector = pyproj.Proj(self.simulator.map.header["projection"])
83
85
 
84
86
  # Step:3 prepare Economy client
85
87
  if "economy" in config["simulator_request"]:
@@ -264,8 +266,9 @@ class AgentGroup:
264
266
  for agent in self.agents:
265
267
  _date_time = datetime.now(timezone.utc)
266
268
  position = await agent.memory.get("position")
267
- lng = position["longlat_position"]["longitude"]
268
- lat = position["longlat_position"]["latitude"]
269
+ x = position["xy_position"]["x"]
270
+ y = position["xy_position"]["y"]
271
+ lng, lat = self.projector(x, y, inverse=True)
269
272
  if "aoi_position" in position:
270
273
  parent_id = position["aoi_position"]["aoi_id"]
271
274
  elif "lane_position" in position:
@@ -379,8 +382,9 @@ class AgentGroup:
379
382
  for agent in self.agents:
380
383
  _date_time = datetime.now(timezone.utc)
381
384
  position = await agent.memory.get("position")
382
- lng = position["longlat_position"]["longitude"]
383
- lat = position["longlat_position"]["latitude"]
385
+ x = position["xy_position"]["x"]
386
+ y = position["xy_position"]["y"]
387
+ lng, lat = self.projector(x, y, inverse=True)
384
388
  if "aoi_position" in position:
385
389
  parent_id = position["aoi_position"]["aoi_id"]
386
390
  elif "lane_position" in position:
@@ -407,8 +411,12 @@ class AgentGroup:
407
411
  }
408
412
  _statuses_time_list.append((_status_dict, _date_time))
409
413
  else:
414
+ # institution
410
415
  for agent in self.agents:
411
416
  _date_time = datetime.now(timezone.utc)
417
+ # ATTENTION: no valid position for an institution
418
+ lng, lat = -1, -1
419
+ parent_id = -1
412
420
  try:
413
421
  nominal_gdp = await agent.memory.get("nominal_gdp")
414
422
  except:
@@ -457,9 +465,9 @@ class AgentGroup:
457
465
  "id": agent._uuid,
458
466
  "day": await self.simulator.get_simulator_day(),
459
467
  "t": await self.simulator.get_simulator_second_from_start_of_day(),
460
- "lng": -1,
461
- "lat": -1,
462
- "parent_id": -1,
468
+ "lng": lng,
469
+ "lat": lat,
470
+ "parent_id": parent_id,
463
471
  "action": "",
464
472
  "type": await agent.memory.get("type"),
465
473
  "nominal_gdp": nominal_gdp,
@@ -148,9 +148,9 @@ class Block:
148
148
  trigger: Optional[EventTrigger] = None,
149
149
  ):
150
150
  self.name = name
151
- self.llm = llm
152
- self.memory = memory
153
- self.simulator = simulator
151
+ self._llm = llm
152
+ self._memory = memory
153
+ self._simulator = simulator
154
154
  # 如果传入trigger,将block注入到trigger中并立即初始化
155
155
  if trigger is not None:
156
156
  trigger.block = self
@@ -163,3 +163,21 @@ class Block:
163
163
  To be overridden by specific block implementations.
164
164
  """
165
165
  raise NotImplementedError("Subclasses should implement this method")
166
+
167
+ @property
168
+ def llm(
169
+ self,
170
+ ) -> LLM:
171
+ return self._llm # type: ignore
172
+
173
+ @property
174
+ def memory(
175
+ self,
176
+ ) -> Memory:
177
+ return self._memory # type: ignore
178
+
179
+ @property
180
+ def simulator(
181
+ self,
182
+ ) -> Simulator:
183
+ return self._simulator # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycityagent
3
- Version: 2.0.0a31
3
+ Version: 2.0.0a33
4
4
  Summary: LLM-based城市环境agent构建库
5
5
  License: MIT
6
6
  Author: Yuwei Yan
@@ -50,7 +50,7 @@ pycityagent/metrics/__init__.py,sha256=X08PaBbGVAd7_PRGLREXWxaqm7nS82WBQpD1zvQzc
50
50
  pycityagent/metrics/mlflow_client.py,sha256=g_tHxWkWTDijtbGL74-HmiYzWVKb1y8-w12QrY9jL30,4449
51
51
  pycityagent/metrics/utils/const.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  pycityagent/simulation/__init__.py,sha256=P5czbcg2d8S0nbbnsQXFIhwzO4CennAhZM8OmKvAeYw,194
53
- pycityagent/simulation/agentgroup.py,sha256=dyUnl76ZlO9ZDwCVtg6hB98dkXSurUsD0ADJyGIlP_I,23587
53
+ pycityagent/simulation/agentgroup.py,sha256=QwVbgqKYp42_wRS3K6C6E7Aq8cYBacabHmXIKRaxYyw,23955
54
54
  pycityagent/simulation/simulation.py,sha256=9kkdgXSEOAN8wiewVFyORksti4IdVNU0opObV6ZYa9k,23344
55
55
  pycityagent/simulation/storage/pg.py,sha256=qGrYzJIAzjv8-d3-cle0rY0AN6XB6MgnHkFLBoLmKWU,7251
56
56
  pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
@@ -66,10 +66,10 @@ pycityagent/utils/parsers/parser_base.py,sha256=KBKO4zLZPNdGjPAGqIus8LseZ8W3Tlt2
66
66
  pycityagent/utils/pg_query.py,sha256=h5158xcrxjUTR0nKwAaG1neFfTHPbN5guLmaXpC8yvs,1918
67
67
  pycityagent/utils/survey_util.py,sha256=Be9nptmu2JtesFNemPgORh_2GsN7rcDYGQS9Zfvc5OI,2169
68
68
  pycityagent/workflow/__init__.py,sha256=QNkUV-9mACMrR8c0cSKna2gC1mMZdxXbxWzjE-Uods0,621
69
- pycityagent/workflow/block.py,sha256=l-z9iJo9_USZQRyj4TLMfihK0-tnNDG0a6jVk9WhG0o,6048
69
+ pycityagent/workflow/block.py,sha256=DeDW6DtIlVS2M6xN_l3kNfGW0JxRAtiAugetc85WpC0,6369
70
70
  pycityagent/workflow/prompt.py,sha256=6jI0Rq54JLv3-IXqZLYug62vse10wTI83xvf4ZX42nk,2929
71
71
  pycityagent/workflow/tool.py,sha256=xADxhNgVsjNiMxlhdwn3xGUstFOkLEG8P67ez8VmwSI,8555
72
72
  pycityagent/workflow/trigger.py,sha256=Df-MOBEDWBbM-v0dFLQLXteLsipymT4n8vqexmK2GiQ,5643
73
- pycityagent-2.0.0a31.dist-info/METADATA,sha256=T-AOPv84-eFtT35uA3WvqIpCkQGoCuxR-Tl_zfSqefI,8033
74
- pycityagent-2.0.0a31.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
75
- pycityagent-2.0.0a31.dist-info/RECORD,,
73
+ pycityagent-2.0.0a33.dist-info/METADATA,sha256=kOVL3RkRLWSJcBAG_6XpQAkv3nH2rAxxB-Z9tKMl-Uc,8033
74
+ pycityagent-2.0.0a33.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
75
+ pycityagent-2.0.0a33.dist-info/RECORD,,