pycityagent 2.0.0a31__tar.gz → 2.0.0a33__tar.gz
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.
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/PKG-INFO +1 -1
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/simulation/agentgroup.py +15 -7
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/workflow/block.py +21 -3
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pyproject.toml +1 -1
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/README.md +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/agent.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/economy/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/economy/econ_client.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/interact/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/interact/interact.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/message/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sence/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sence/static.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sidecar/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sidecar/sidecarv2.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/aoi_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/client.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/clock_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/economy_services.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/lane_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/light_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/person_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/road_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/sim_env.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/social_service.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/simulator.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/base64.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/const.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/geojson.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/grpc.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/map_utils.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/port.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/utils/protobuf.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/llm/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/llm/embeddings.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/llm/llm.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/llm/llmconfig.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/llm/utils.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/const.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/faiss_query.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/memory.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/memory_base.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/profile.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/self_define.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/state.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/memory/utils.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/message/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/message/messager.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/metrics/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/metrics/mlflow_client.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/metrics/utils/const.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/simulation/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/simulation/simulation.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/simulation/storage/pg.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/survey/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/survey/manager.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/survey/models.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/avro_schema.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/decorators.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/parsers/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/parsers/code_block_parser.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/parsers/json_parser.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/parsers/parser_base.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/pg_query.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/survey_util.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/workflow/__init__.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/workflow/prompt.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/workflow/tool.py +0 -0
- {pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/workflow/trigger.py +0 -0
@@ -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
|
-
|
268
|
-
|
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
|
-
|
383
|
-
|
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":
|
461
|
-
"lat":
|
462
|
-
"parent_id":
|
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.
|
152
|
-
self.
|
153
|
-
self.
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/environment/sim/economy_services.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pycityagent-2.0.0a31 → pycityagent-2.0.0a33}/pycityagent/utils/parsers/code_block_parser.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|