pycityagent 2.0.0a84__cp39-cp39-macosx_11_0_arm64.whl → 2.0.0a87__cp39-cp39-macosx_11_0_arm64.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.
- pycityagent/cityagent/blocks/economy_block.py +5 -12
- pycityagent/cityagent/memory_config.py +1 -0
- pycityagent/cityagent/metrics.py +18 -7
- pycityagent/cityagent/nbsagent.py +3 -1
- pycityagent/economy/econ_client.py +35 -69
- pycityagent/environment/simulator.py +39 -25
- pycityagent/simulation/agentgroup.py +2 -7
- pycityagent/simulation/simulation.py +3 -1
- {pycityagent-2.0.0a84.dist-info → pycityagent-2.0.0a87.dist-info}/METADATA +1 -1
- {pycityagent-2.0.0a84.dist-info → pycityagent-2.0.0a87.dist-info}/RECORD +14 -14
- {pycityagent-2.0.0a84.dist-info → pycityagent-2.0.0a87.dist-info}/LICENSE +0 -0
- {pycityagent-2.0.0a84.dist-info → pycityagent-2.0.0a87.dist-info}/WHEEL +0 -0
- {pycityagent-2.0.0a84.dist-info → pycityagent-2.0.0a87.dist-info}/entry_points.txt +0 -0
- {pycityagent-2.0.0a84.dist-info → pycityagent-2.0.0a87.dist-info}/top_level.txt +0 -0
@@ -112,14 +112,6 @@ class ConsumptionBlock(Block):
|
|
112
112
|
for i in range(len(firms_id)):
|
113
113
|
demand_each_firm.append(int(consumption_each_firm[i]//prices[i]))
|
114
114
|
real_consumption = await self.economy_client.calculate_consumption(firms_id, agent_id, demand_each_firm)
|
115
|
-
if real_consumption == -1:
|
116
|
-
node_id = await self.memory.stream.add_economy(description=f"I failed to buy goods, cause I do not have enough money.")
|
117
|
-
return {
|
118
|
-
'success': False,
|
119
|
-
'evaluation': f"I failed to buy goods, cause I do not have enough money.",
|
120
|
-
'consumed_time': 0,
|
121
|
-
'node_id': node_id
|
122
|
-
}
|
123
115
|
node_id = await self.memory.stream.add_economy(description=f"I bought some goods, and spent {real_consumption:.1f} on {intention}")
|
124
116
|
evaluation = {
|
125
117
|
'success': True,
|
@@ -281,8 +273,8 @@ class MonthPlanBlock(Block):
|
|
281
273
|
work_propensity = await self.memory.status.get('work_propensity')
|
282
274
|
consumption_propensity = await self.memory.status.get('consumption_propensity')
|
283
275
|
work_hours = work_propensity * self.num_labor_hours
|
284
|
-
income = await self.economy_client.get(agent_id, 'income')
|
285
|
-
income
|
276
|
+
# income = await self.economy_client.get(agent_id, 'income')
|
277
|
+
income = work_hours * work_skill
|
286
278
|
|
287
279
|
wealth = await self.economy_client.get(agent_id, 'currency')
|
288
280
|
wealth += work_hours * work_skill
|
@@ -348,7 +340,7 @@ class MonthPlanBlock(Block):
|
|
348
340
|
except:
|
349
341
|
self.llm_error += 1
|
350
342
|
|
351
|
-
if self.UBI and self.forward_times >= 96 and self.forward_times % 12:
|
343
|
+
if self.UBI and self.forward_times >= 96 and self.forward_times % 12 == 0:
|
352
344
|
obs_prompt = f'''
|
353
345
|
{problem_prompt} {job_prompt} {consumption_prompt} {tax_prompt} {price_prompt}
|
354
346
|
Your current savings account balance is ${wealth:.2f}. Interest rates, as set by your bank, stand at {interest_rate*100:.2f}%.
|
@@ -357,4 +349,5 @@ class MonthPlanBlock(Block):
|
|
357
349
|
obs_prompt = prettify_document(obs_prompt)
|
358
350
|
content = await self.llm.atext_request([{'role': 'user', 'content': obs_prompt}], timeout=300)
|
359
351
|
await self.memory.status.update('ubi_opinion', [content], mode='merge')
|
360
|
-
|
352
|
+
|
353
|
+
self.forward_times += 1
|
pycityagent/cityagent/metrics.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import pycityproto.city.economy.v2.economy_pb2 as economyv2
|
2
|
-
from pycityagent.cityagent import SocietyAgent
|
2
|
+
from pycityagent.cityagent import SocietyAgent, NBSAgent
|
3
3
|
|
4
4
|
async def mobility_metric(simulation):
|
5
5
|
# 使用函数属性来存储计数
|
@@ -22,20 +22,31 @@ async def mobility_metric(simulation):
|
|
22
22
|
async def economy_metric(simulation):
|
23
23
|
# 使用函数属性来存储计数
|
24
24
|
if not hasattr(economy_metric, 'step_count'):
|
25
|
-
economy_metric.
|
25
|
+
economy_metric.nbs_id = None
|
26
|
+
economy_metric.nbs_uuid = None
|
27
|
+
|
28
|
+
if economy_metric.nbs_id is None:
|
29
|
+
nbs_id = await simulation.economy_client.get_org_entity_ids(economyv2.ORG_TYPE_NBS)
|
30
|
+
nbs_id = nbs_id[0]
|
31
|
+
economy_metric.nbs_id = nbs_id
|
32
|
+
nbs_uuids = await simulation.filter(types=[NBSAgent])
|
33
|
+
economy_metric.nbs_uuid = nbs_uuids[0]
|
26
34
|
|
27
|
-
nbs_id = await simulation.economy_client.get_org_entity_ids(economyv2.ORG_TYPE_NBS)
|
28
|
-
nbs_id = nbs_id[0]
|
29
35
|
try:
|
30
36
|
real_gdp = await simulation.economy_client.get(nbs_id, 'real_gdp')
|
31
37
|
except:
|
32
38
|
real_gdp = []
|
33
39
|
if len(real_gdp) > 0:
|
34
40
|
real_gdp = real_gdp[0]
|
35
|
-
await simulation.
|
41
|
+
forward_times_info = await simulation.gather("forward_times", [economy_metric.nbs_uuid])
|
42
|
+
step_count = 0
|
43
|
+
for group_gather in forward_times_info:
|
44
|
+
for agent_uuid, forward_times in group_gather.items():
|
45
|
+
if agent_uuid == economy_metric.nbs_uuid:
|
46
|
+
step_count = forward_times
|
47
|
+
await simulation.mlflow_client.log_metric(key="real_gdp", value=real_gdp, step=step_count)
|
36
48
|
other_metrics = ['prices', 'working_hours', 'depression', 'consumption_currency', 'income_currency']
|
37
49
|
other_metrics_names = ['price', 'working_hours', 'depression', 'consumption', 'income']
|
38
50
|
for metric, metric_name in zip(other_metrics, other_metrics_names):
|
39
51
|
metric_value = (await simulation.economy_client.get(nbs_id, metric))[-1]
|
40
|
-
await simulation.mlflow_client.log_metric(key=metric_name, value=metric_value, step=
|
41
|
-
economy_metric.step_count += 1
|
52
|
+
await simulation.mlflow_client.log_metric(key=metric_name, value=metric_value, step=step_count)
|
@@ -115,4 +115,6 @@ class NBSAgent(InstitutionAgent):
|
|
115
115
|
await self.economy_client.update(
|
116
116
|
self._agent_id, "income_currency", [income_currency], mode="merge"
|
117
117
|
)
|
118
|
-
print("nbs forward end")
|
118
|
+
print("nbs forward end")
|
119
|
+
self.forward_times += 1
|
120
|
+
await self.memory.status.update("forward_times", self.forward_times)
|
@@ -3,7 +3,7 @@ import logging
|
|
3
3
|
import re
|
4
4
|
import time
|
5
5
|
from collections.abc import Sequence
|
6
|
-
from typing import Any, Literal, Union
|
6
|
+
from typing import Any, Literal, Union, cast
|
7
7
|
|
8
8
|
import grpc
|
9
9
|
import pycityproto.city.economy.v2.economy_pb2 as economyv2
|
@@ -83,17 +83,18 @@ class EconomyClient:
|
|
83
83
|
- It establishes an asynchronous connection and provides methods to communicate with the service.
|
84
84
|
"""
|
85
85
|
|
86
|
-
def __init__(
|
86
|
+
def __init__(
|
87
|
+
self,
|
88
|
+
server_address: str,
|
89
|
+
):
|
87
90
|
"""
|
88
91
|
Initialize the EconomyClient.
|
89
92
|
|
90
93
|
- **Args**:
|
91
94
|
- `server_address` (`str`): The address of the Economy server to connect to.
|
92
|
-
- `secure` (`bool`, optional): Whether to use a secure connection. Defaults to `False`.
|
93
95
|
|
94
96
|
- **Attributes**:
|
95
97
|
- `server_address` (`str`): The address of the Economy server.
|
96
|
-
- `secure` (`bool`): A flag indicating if a secure connection should be used.
|
97
98
|
- `_aio_stub` (`OrgServiceStub`): A gRPC stub used to make remote calls to the Economy service.
|
98
99
|
|
99
100
|
- **Description**:
|
@@ -102,6 +103,8 @@ class EconomyClient:
|
|
102
103
|
- Instantiates a gRPC stub (`_aio_stub`) for interacting with the Economy service.
|
103
104
|
"""
|
104
105
|
self.server_address = server_address
|
106
|
+
|
107
|
+
secure = self.server_address.startswith("https")
|
105
108
|
self.secure = secure
|
106
109
|
aio_channel = _create_aio_channel(server_address, secure)
|
107
110
|
self._aio_stub = org_grpc.OrgServiceStub(aio_channel)
|
@@ -149,7 +152,9 @@ class EconomyClient:
|
|
149
152
|
self._agent_ids = agent_ids
|
150
153
|
self._org_ids = org_ids
|
151
154
|
|
152
|
-
async def get_agent(
|
155
|
+
async def get_agent(
|
156
|
+
self, id: Union[list[int], int]
|
157
|
+
) -> Union[dict[str, Any], list[dict[str, Any]]]:
|
153
158
|
"""
|
154
159
|
Get agent by id
|
155
160
|
|
@@ -160,17 +165,10 @@ class EconomyClient:
|
|
160
165
|
- `economyv2.Agent`: The agent object.
|
161
166
|
"""
|
162
167
|
start_time = time.time()
|
163
|
-
log = {
|
164
|
-
"req": "get_agent",
|
165
|
-
"start_time": start_time,
|
166
|
-
"consumption": 0
|
167
|
-
}
|
168
|
+
log = {"req": "get_agent", "start_time": start_time, "consumption": 0}
|
168
169
|
if isinstance(id, list):
|
169
170
|
agents = await self._aio_stub.BatchGet(
|
170
|
-
org_service.BatchGetRequest(
|
171
|
-
ids=id,
|
172
|
-
type="agent"
|
173
|
-
)
|
171
|
+
org_service.BatchGetRequest(ids=id, type="agent")
|
174
172
|
)
|
175
173
|
agents = MessageToDict(agents)["agents"]
|
176
174
|
agent_dicts = [camel_to_snake(agent) for agent in agents]
|
@@ -179,16 +177,16 @@ class EconomyClient:
|
|
179
177
|
return agent_dicts
|
180
178
|
else:
|
181
179
|
agent = await self._aio_stub.GetAgent(
|
182
|
-
org_service.GetAgentRequest(
|
183
|
-
agent_id=id
|
184
|
-
)
|
180
|
+
org_service.GetAgentRequest(agent_id=id)
|
185
181
|
)
|
186
182
|
agent_dict = MessageToDict(agent)["agent"]
|
187
183
|
log["consumption"] = time.time() - start_time
|
188
184
|
self._log_list.append(log)
|
189
185
|
return camel_to_snake(agent_dict)
|
190
186
|
|
191
|
-
async def get_org(
|
187
|
+
async def get_org(
|
188
|
+
self, id: Union[list[int], int]
|
189
|
+
) -> Union[dict[str, Any], list[dict[str, Any]]]:
|
192
190
|
"""
|
193
191
|
Get org by id
|
194
192
|
|
@@ -199,17 +197,10 @@ class EconomyClient:
|
|
199
197
|
- `economyv2.Org`: The org object.
|
200
198
|
"""
|
201
199
|
start_time = time.time()
|
202
|
-
log = {
|
203
|
-
"req": "get_org",
|
204
|
-
"start_time": start_time,
|
205
|
-
"consumption": 0
|
206
|
-
}
|
200
|
+
log = {"req": "get_org", "start_time": start_time, "consumption": 0}
|
207
201
|
if isinstance(id, list):
|
208
202
|
orgs = await self._aio_stub.BatchGet(
|
209
|
-
org_service.BatchGetRequest(
|
210
|
-
ids=id,
|
211
|
-
type="org"
|
212
|
-
)
|
203
|
+
org_service.BatchGetRequest(ids=id, type="org")
|
213
204
|
)
|
214
205
|
orgs = MessageToDict(orgs)["orgs"]
|
215
206
|
org_dicts = [camel_to_snake(org) for org in orgs]
|
@@ -217,11 +208,7 @@ class EconomyClient:
|
|
217
208
|
self._log_list.append(log)
|
218
209
|
return org_dicts
|
219
210
|
else:
|
220
|
-
org = await self._aio_stub.GetOrg(
|
221
|
-
org_service.GetOrgRequest(
|
222
|
-
org_id=id
|
223
|
-
)
|
224
|
-
)
|
211
|
+
org = await self._aio_stub.GetOrg(org_service.GetOrgRequest(org_id=id))
|
225
212
|
org_dict = MessageToDict(org)["org"]
|
226
213
|
log["consumption"] = time.time() - start_time
|
227
214
|
self._log_list.append(log)
|
@@ -243,18 +230,15 @@ class EconomyClient:
|
|
243
230
|
- Any
|
244
231
|
"""
|
245
232
|
start_time = time.time()
|
246
|
-
log = {
|
247
|
-
|
248
|
-
"start_time": start_time,
|
249
|
-
"consumption": 0
|
250
|
-
}
|
251
|
-
if isinstance(id, list):
|
233
|
+
log = {"req": "get", "start_time": start_time, "consumption": 0}
|
234
|
+
if isinstance(id, Sequence):
|
252
235
|
requests = "Org" if id[0] in self._org_ids else "Agent"
|
253
236
|
if requests == "Org":
|
254
237
|
response = await self.get_org(id)
|
255
238
|
else:
|
256
239
|
response = await self.get_agent(id)
|
257
240
|
results = []
|
241
|
+
response = cast(list[dict[str, Any]], response)
|
258
242
|
for res in response:
|
259
243
|
results.append(res[key])
|
260
244
|
log["consumption"] = time.time() - start_time
|
@@ -268,10 +252,11 @@ class EconomyClient:
|
|
268
252
|
response = await self.get_org(id)
|
269
253
|
else:
|
270
254
|
response = await self.get_agent(id)
|
255
|
+
response = cast(dict[str, Any], response)
|
271
256
|
log["consumption"] = time.time() - start_time
|
272
257
|
self._log_list.append(log)
|
273
258
|
return response[key]
|
274
|
-
|
259
|
+
|
275
260
|
def _merge(self, original_value, key, value):
|
276
261
|
try:
|
277
262
|
orig_value = original_value[key]
|
@@ -321,16 +306,14 @@ class EconomyClient:
|
|
321
306
|
- Any
|
322
307
|
"""
|
323
308
|
start_time = time.time()
|
324
|
-
log = {
|
325
|
-
"req": "update",
|
326
|
-
"start_time": start_time,
|
327
|
-
"consumption": 0
|
328
|
-
}
|
309
|
+
log = {"req": "update", "start_time": start_time, "consumption": 0}
|
329
310
|
if isinstance(id, list):
|
330
311
|
if not isinstance(value, list):
|
331
312
|
raise ValueError(f"Invalid value, the value must be a list!")
|
332
313
|
if len(id) != len(value):
|
333
|
-
raise ValueError(
|
314
|
+
raise ValueError(
|
315
|
+
f"Invalid ids and values, the length of ids and values must be the same!"
|
316
|
+
)
|
334
317
|
request_type = "Org" if id[0] in self._org_ids else "Agent"
|
335
318
|
else:
|
336
319
|
if id not in self._agent_ids and id not in self._org_ids:
|
@@ -363,16 +346,11 @@ class EconomyClient:
|
|
363
346
|
# ))
|
364
347
|
# await asyncio.gather(*batch_update_tasks)
|
365
348
|
await self._aio_stub.BatchUpdate(
|
366
|
-
org_service.BatchUpdateRequest(
|
367
|
-
orgs=original_value,
|
368
|
-
agents=None
|
369
|
-
)
|
349
|
+
org_service.BatchUpdateRequest(orgs=original_value, agents=None)
|
370
350
|
)
|
371
351
|
else:
|
372
352
|
await self._aio_stub.UpdateOrg(
|
373
|
-
org_service.UpdateOrgRequest(
|
374
|
-
org=original_value
|
375
|
-
)
|
353
|
+
org_service.UpdateOrgRequest(org=original_value)
|
376
354
|
)
|
377
355
|
log["consumption"] = time.time() - start_time
|
378
356
|
self._log_list.append(log)
|
@@ -387,16 +365,11 @@ class EconomyClient:
|
|
387
365
|
# ))
|
388
366
|
# await asyncio.gather(*batch_update_tasks)
|
389
367
|
await self._aio_stub.BatchUpdate(
|
390
|
-
org_service.BatchUpdateRequest(
|
391
|
-
orgs=None,
|
392
|
-
agents=original_value
|
393
|
-
)
|
368
|
+
org_service.BatchUpdateRequest(orgs=None, agents=original_value)
|
394
369
|
)
|
395
370
|
else:
|
396
371
|
await self._aio_stub.UpdateAgent(
|
397
|
-
org_service.UpdateAgentRequest(
|
398
|
-
agent=original_value
|
399
|
-
)
|
372
|
+
org_service.UpdateAgentRequest(agent=original_value)
|
400
373
|
)
|
401
374
|
log["consumption"] = time.time() - start_time
|
402
375
|
self._log_list.append(log)
|
@@ -572,18 +545,11 @@ class EconomyClient:
|
|
572
545
|
return response.actual_consumption
|
573
546
|
else:
|
574
547
|
return -1
|
575
|
-
|
576
|
-
|
548
|
+
|
577
549
|
async def calculate_real_gdp(self, nbs_id: int):
|
578
550
|
start_time = time.time()
|
579
|
-
log = {
|
580
|
-
|
581
|
-
"start_time": start_time,
|
582
|
-
"consumption": 0
|
583
|
-
}
|
584
|
-
request = org_service.CalculateRealGDPRequest(
|
585
|
-
nbs_agent_id=nbs_id
|
586
|
-
)
|
551
|
+
log = {"req": "calculate_real_gdp", "start_time": start_time, "consumption": 0}
|
552
|
+
request = org_service.CalculateRealGDPRequest(nbs_agent_id=nbs_id)
|
587
553
|
response: org_service.CalculateRealGDPResponse = (
|
588
554
|
await self._aio_stub.CalculateRealGDP(request)
|
589
555
|
)
|
@@ -87,49 +87,64 @@ class Simulator:
|
|
87
87
|
- 模拟器配置
|
88
88
|
- simulator config
|
89
89
|
"""
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
90
|
+
_map_request = config["map_request"]
|
91
|
+
if "file_path" not in _map_request:
|
92
|
+
# from mongo db
|
93
|
+
_mongo_uri, _mongo_db, _mongo_coll, _map_cache_dir = (
|
94
|
+
_map_request["mongo_uri"],
|
95
|
+
_map_request["mongo_db"],
|
96
|
+
_map_request["mongo_coll"],
|
97
|
+
_map_request["cache_dir"],
|
98
|
+
)
|
99
|
+
_mongo_client = MongoClient(_mongo_uri)
|
100
|
+
os.makedirs(_map_cache_dir, exist_ok=True)
|
101
|
+
_map_pb_path = os.path.join(_map_cache_dir, f"{_mongo_db}.{_mongo_coll}.pb") # type: ignore
|
102
|
+
_map_pb = map_pb2.Map()
|
103
|
+
if os.path.exists(_map_pb_path):
|
104
|
+
with open(_map_pb_path, "rb") as f:
|
105
|
+
_map_pb.ParseFromString(f.read())
|
106
|
+
else:
|
107
|
+
_map_pb = coll2pb(_mongo_client[_mongo_db][_mongo_coll], _map_pb)
|
108
|
+
with open(_map_pb_path, "wb") as f:
|
109
|
+
f.write(_map_pb.SerializeToString())
|
103
110
|
else:
|
104
|
-
|
105
|
-
|
106
|
-
|
111
|
+
# from local file
|
112
|
+
_mongo_uri, _mongo_db, _mongo_coll, _map_cache_dir = "", "", "", ""
|
113
|
+
_map_pb_path = _map_request["file_path"]
|
107
114
|
|
108
115
|
if "simulator" in config:
|
109
116
|
if config["simulator"] is None:
|
110
117
|
config["simulator"] = {}
|
111
|
-
if
|
118
|
+
if not config["simulator"].get("_server_activated", False):
|
112
119
|
self._sim_env = sim_env = ControlSimEnv(
|
113
120
|
task_name=config["simulator"].get("task", "citysim"),
|
114
121
|
map_file=_map_pb_path,
|
115
122
|
max_day=config["simulator"].get("max_day", 1000),
|
116
123
|
start_step=config["simulator"].get("start_step", 28800),
|
117
|
-
total_step=config["simulator"].get(
|
124
|
+
total_step=config["simulator"].get(
|
125
|
+
"total_step", 24 * 60 * 60 * 365
|
126
|
+
),
|
118
127
|
log_dir=config["simulator"].get("log_dir", "./log"),
|
119
128
|
min_step_time=config["simulator"].get("min_step_time", 1000),
|
120
129
|
sim_addr=config["simulator"].get("server", None),
|
121
130
|
)
|
122
|
-
|
131
|
+
primary_node_ip = config["simulator"].get("ad", "http://localhost")
|
132
|
+
self.server_addr = primary_node_ip.rstrip("/")+f":{sim_env.sim_port}"
|
123
133
|
config["simulator"]["server"] = self.server_addr
|
134
|
+
config["simulator"]["_server_activated"] = True
|
124
135
|
# using local client
|
125
|
-
self._client = CityClient(
|
136
|
+
self._client = CityClient(
|
137
|
+
sim_env.sim_addr, secure=self.server_addr.startswith("https")
|
138
|
+
)
|
126
139
|
"""
|
127
140
|
- 模拟器grpc客户端
|
128
141
|
- grpc client of simulator
|
129
142
|
"""
|
130
143
|
else:
|
131
|
-
self._client = CityClient(config["simulator"]["server"], secure=False)
|
132
144
|
self.server_addr = config["simulator"]["server"]
|
145
|
+
self._client = CityClient(
|
146
|
+
self.server_addr, secure=self.server_addr.startswith("https")
|
147
|
+
)
|
133
148
|
else:
|
134
149
|
self.server_addr = None
|
135
150
|
logger.warning(
|
@@ -141,10 +156,9 @@ class Simulator:
|
|
141
156
|
- Simulator map object
|
142
157
|
"""
|
143
158
|
if create_map:
|
144
|
-
_map_cache_path = "" # 地图pb文件路径
|
145
159
|
self._map = CityMap.remote(
|
146
160
|
(_mongo_uri, _mongo_db, _mongo_coll, _map_cache_dir),
|
147
|
-
|
161
|
+
_map_pb_path,
|
148
162
|
)
|
149
163
|
self._create_poi_id_2_aoi_id()
|
150
164
|
|
@@ -363,7 +377,7 @@ class Simulator:
|
|
363
377
|
log = {"req": "get_simulator_day", "start_time": start_time, "consumption": 0}
|
364
378
|
now = await self._client.clock_service.Now({})
|
365
379
|
now = cast(dict[str, int], now)
|
366
|
-
day = int(now["t"]//(24*60*60))
|
380
|
+
day = int(now["t"] // (24 * 60 * 60))
|
367
381
|
log["consumption"] = time.time() - start_time
|
368
382
|
self._log_list.append(log)
|
369
383
|
return day
|
@@ -385,7 +399,7 @@ class Simulator:
|
|
385
399
|
now = cast(dict[str, int], now)
|
386
400
|
log["consumption"] = time.time() - start_time
|
387
401
|
self._log_list.append(log)
|
388
|
-
return now["t"]%(24*60*60)
|
402
|
+
return now["t"] % (24 * 60 * 60)
|
389
403
|
|
390
404
|
async def get_person(self, person_id: int) -> dict:
|
391
405
|
"""
|
@@ -22,13 +22,8 @@ from ..llm.llmconfig import LLMConfig
|
|
22
22
|
from ..memory import FaissQuery, Memory
|
23
23
|
from ..message import Messager
|
24
24
|
from ..metrics import MlflowClient
|
25
|
-
from ..utils import (
|
26
|
-
|
27
|
-
INSTITUTION_STATUS_SCHEMA,
|
28
|
-
PROFILE_SCHEMA,
|
29
|
-
STATUS_SCHEMA,
|
30
|
-
SURVEY_SCHEMA,
|
31
|
-
)
|
25
|
+
from ..utils import (DIALOG_SCHEMA, INSTITUTION_STATUS_SCHEMA, PROFILE_SCHEMA,
|
26
|
+
STATUS_SCHEMA, SURVEY_SCHEMA)
|
32
27
|
|
33
28
|
logger = logging.getLogger("pycityagent")
|
34
29
|
__all__ = ["AgentGroup"]
|
@@ -1021,7 +1021,9 @@ class AgentSimulation:
|
|
1021
1021
|
try:
|
1022
1022
|
# step
|
1023
1023
|
simulator_day = await self._simulator.get_simulator_day()
|
1024
|
-
simulator_time = int(
|
1024
|
+
simulator_time = int(
|
1025
|
+
await self._simulator.get_simulator_second_from_start_of_day()
|
1026
|
+
)
|
1025
1027
|
logger.info(
|
1026
1028
|
f"Start simulation day {simulator_day} at {simulator_time}, step {self._total_steps}"
|
1027
1029
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: pycityagent
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.0a87
|
4
4
|
Summary: LLM-based city environment agent building library
|
5
5
|
Author-email: Yuwei Yan <pinkgranite86@gmail.com>, Junbo Yan <yanjb20thu@gmali.com>, Jun Zhang <zhangjun990222@gmali.com>
|
6
6
|
License: MIT License
|
@@ -4,7 +4,7 @@ pycityagent/pycityagent-ui,sha256=Ur95yZygIaZ5l_CDqP9394M5GQ66iV5PkcNPYFWqzvk,41
|
|
4
4
|
pycityagent/metrics/mlflow_client.py,sha256=-iyh4BPVnBkluhmfucUzibCUnBX2iftkz4tVJJVxwHw,6958
|
5
5
|
pycityagent/metrics/__init__.py,sha256=X08PaBbGVAd7_PRGLREXWxaqm7nS82WBQpD1zvQzcqc,128
|
6
6
|
pycityagent/economy/__init__.py,sha256=aonY4WHnx-6EGJ4WKrx4S-2jAkYNLtqUA04jp6q8B7w,75
|
7
|
-
pycityagent/economy/econ_client.py,sha256=
|
7
|
+
pycityagent/economy/econ_client.py,sha256=KXoRKnOrqYlFqgLHpNim1C5QRM7QPO3GtXG1Aq-yf6U,28621
|
8
8
|
pycityagent/tools/__init__.py,sha256=y7sMVMHf0AbivlczM2h-kr7mkgXK-WAx3S9BXLXkWvw,235
|
9
9
|
pycityagent/tools/tool.py,sha256=4ZJSHbNM8dfAVwZEw8T0a2_9OuPsPQpKSVL4WxZVBUc,9022
|
10
10
|
pycityagent/llm/llmconfig.py,sha256=6AqCMV4B_JqBD2mb98bLGzpUdlOCnziQKae-Hhxxp-E,469
|
@@ -21,9 +21,9 @@ pycityagent/memory/utils.py,sha256=oJWLdPeJy_jcdKcDTo9JAH9kDZhqjoQhhv_zT9qWC0w,8
|
|
21
21
|
pycityagent/memory/const.py,sha256=nFmjvt-8FEB0hc0glOH3lliqJhkhf3D_NKxWI0pf6TY,936
|
22
22
|
pycityagent/memory/faiss_query.py,sha256=KPeyzIjD0dzkxr-TlOeCiIlkdh1WAyyipCAXUEt97Lk,17350
|
23
23
|
pycityagent/memory/state.py,sha256=JFCBuK1AS-HqscvdGS9ATF9AUU8t29_2leDY_6iO2_4,5158
|
24
|
-
pycityagent/simulation/simulation.py,sha256=
|
24
|
+
pycityagent/simulation/simulation.py,sha256=bHpR3FtUM6ewurwByRr57OgdTWXTPq9-knIjGt2GHlo,49370
|
25
25
|
pycityagent/simulation/__init__.py,sha256=u1WpgwVxPboXWMxrUQKMXJNmTKQYAeCaqZv9HmSxESY,118
|
26
|
-
pycityagent/simulation/agentgroup.py,sha256=
|
26
|
+
pycityagent/simulation/agentgroup.py,sha256=rPloocCwB6rfjWbIz3T052mYq2lEcBp97mblkMD2y0A,36955
|
27
27
|
pycityagent/simulation/storage/pg.py,sha256=xRshSOGttW-p0re0fNBOjOpb-nQ5msIE2LsdT79_E_Y,8425
|
28
28
|
pycityagent/message/message_interceptor.py,sha256=QWuTUqi1Cu214fhFs0f78tD2zflMnb6zEAGB4RutXxs,17736
|
29
29
|
pycityagent/message/__init__.py,sha256=f5QH7DKPqEAMyfSlBMnl3uouOKlsoel909STlIe7nUk,276
|
@@ -46,7 +46,7 @@ pycityagent/workflow/prompt.py,sha256=rzenP4EFGxbWE1aq-x2036b6umKvi5cQx2xtWULwgI
|
|
46
46
|
pycityagent/workflow/block.py,sha256=WJfCeL8e117GzkVPJCRNsQZZinccMnVyEubkwrf-17U,12295
|
47
47
|
pycityagent/workflow/trigger.py,sha256=4nzAwywGQsFabgo6gzp-vD2EV4wII7Z0LHGEAsflSEY,7608
|
48
48
|
pycityagent/environment/__init__.py,sha256=fFIth2jxxgZ92cXm-aoM2igHgaSqsYGwtBhyb7opjzk,166
|
49
|
-
pycityagent/environment/simulator.py,sha256=
|
49
|
+
pycityagent/environment/simulator.py,sha256=ubOsoeyo81LZKfOSeS4eGrpn-7lC-hrdCBbcLH9NbK8,23324
|
50
50
|
pycityagent/environment/utils/port.py,sha256=3OM6kSUt3PxvDUOlgyiendBtETaWU8Mzk_8H0TzTmYg,295
|
51
51
|
pycityagent/environment/utils/grpc.py,sha256=_lB4-k4dTKuNvApaDiYgFxiLTPtYG42DVQtG9yOj9pQ,2022
|
52
52
|
pycityagent/environment/utils/base64.py,sha256=hoREzQo3FXMN79pqQLO2jgsDEvudciomyKii7MWljAM,374
|
@@ -66,12 +66,12 @@ pycityagent/environment/sim/social_service.py,sha256=Y4A56aKXsjSv18UFumGPjQoJVMc
|
|
66
66
|
pycityagent/environment/sim/light_service.py,sha256=q4pKcGrm7WU0h29I1dFIDOz2OV0BM-2s37uC6zokkoA,4290
|
67
67
|
pycityagent/environment/sim/clock_service.py,sha256=4Hly8CToghj0x_XbDgGrIZy1YYAlDH0EUGCiCDYpk_I,1375
|
68
68
|
pycityagent/environment/sim/road_service.py,sha256=Bb1sreO0Knt9tcqH_WJF-I3P3G92bRAlzDBEa--25GE,1297
|
69
|
-
pycityagent/cityagent/metrics.py,sha256=
|
70
|
-
pycityagent/cityagent/memory_config.py,sha256=
|
69
|
+
pycityagent/cityagent/metrics.py,sha256=SdCxEuO-wgsPGo3H6xywnOAfP5Lre-bc7HNAQ-n53mA,2687
|
70
|
+
pycityagent/cityagent/memory_config.py,sha256=lCySjh8jpE3Sj-_XTCPizxJN8rjfcYD54sed7wi2EDw,11958
|
71
71
|
pycityagent/cityagent/bankagent.py,sha256=I6MNG1fUbxKyWCLxCtvOjeVahong_LhHQKmJdRPhQL8,4097
|
72
72
|
pycityagent/cityagent/__init__.py,sha256=gcBQ-a50XegFtjigQ7xDXRBZrywBKqifiQFSRnEF8gM,572
|
73
73
|
pycityagent/cityagent/firmagent.py,sha256=vZr7kdjnxcCZ5qX7hmUIYuQQWd44GcRPbdi76WGSFy4,3760
|
74
|
-
pycityagent/cityagent/nbsagent.py,sha256=
|
74
|
+
pycityagent/cityagent/nbsagent.py,sha256=rrzL-Ep-gWB8kvoPA8nBokY1zoEZGpyQjP9oy7ZuVL4,4676
|
75
75
|
pycityagent/cityagent/initial.py,sha256=0DSOWnVVknMw6xoJWfdZUFBH3yti8y800wnkXXCocxY,6194
|
76
76
|
pycityagent/cityagent/societyagent.py,sha256=1c6k3RgxQ7AAYCiBXwiSZLDkCDMgCrBzNF6vi6lK2Yc,20069
|
77
77
|
pycityagent/cityagent/message_intercept.py,sha256=dyT1G-nMxKb2prhgtyFFHFz593qBrkk5DnHsHvG1OIc,4418
|
@@ -81,7 +81,7 @@ pycityagent/cityagent/blocks/needs_block.py,sha256=NYKrGDoYCuXoupMNMuSNhx4Ci1paC
|
|
81
81
|
pycityagent/cityagent/blocks/cognition_block.py,sha256=yzjB0D_95vytpa5xiVdmTSpGp8H9HXcjWzzFN0OpP0k,15398
|
82
82
|
pycityagent/cityagent/blocks/social_block.py,sha256=eedOlwRTGI47QFELYmfe2a_aj0GuHJweSyDxA6AYXcU,15493
|
83
83
|
pycityagent/cityagent/blocks/__init__.py,sha256=h6si6WBcVVuglIskKQKA8Cxtf_VKen1sNPqOFKI311Q,420
|
84
|
-
pycityagent/cityagent/blocks/economy_block.py,sha256=
|
84
|
+
pycityagent/cityagent/blocks/economy_block.py,sha256=ZhNzhkXxzFidQQRLS5jNv5msHSdoASouKBqvAzecJU4,19709
|
85
85
|
pycityagent/cityagent/blocks/utils.py,sha256=K--6odjUDUu9YrwrHPaiPIHryo7m_MBmcBqDAy3cV5M,1816
|
86
86
|
pycityagent/cityagent/blocks/other_block.py,sha256=LdtL6248xvMvvRQx6NvdlJrWWZFu8Xusjxb9yEh1M0k,4365
|
87
87
|
pycityagent/cityagent/blocks/plan_block.py,sha256=A5DvtXIy98MZkRGUQmp26grNI5i0BVbl3aEM_Ebd6Z4,11271
|
@@ -89,9 +89,9 @@ pycityagent/cityagent/blocks/mobility_block.py,sha256=qkRiV0nkGOUUoo9lGIjAFE_Hl0
|
|
89
89
|
pycityagent/survey/models.py,sha256=g3xni4GcA1Py3vlGt6z4ltutjgQ4G0uINYAM8vKRJAw,5225
|
90
90
|
pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
|
91
91
|
pycityagent/survey/manager.py,sha256=tHkdeq4lTfAHwvgf4-udsXri0z2l6E00rEbvwl7SqRs,3439
|
92
|
-
pycityagent-2.0.
|
93
|
-
pycityagent-2.0.
|
94
|
-
pycityagent-2.0.
|
95
|
-
pycityagent-2.0.
|
96
|
-
pycityagent-2.0.
|
97
|
-
pycityagent-2.0.
|
92
|
+
pycityagent-2.0.0a87.dist-info/RECORD,,
|
93
|
+
pycityagent-2.0.0a87.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
|
94
|
+
pycityagent-2.0.0a87.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
|
95
|
+
pycityagent-2.0.0a87.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
|
96
|
+
pycityagent-2.0.0a87.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
|
97
|
+
pycityagent-2.0.0a87.dist-info/METADATA,sha256=nhB__BcNLDfb1PCA7Wjb5GWYo7mRegc1KPQFypOERlk,9110
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|