pycityagent 2.0.0a67__cp39-cp39-macosx_11_0_arm64.whl → 2.0.0a69__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.
@@ -110,8 +110,7 @@ class ConsumptionBlock(Block):
110
110
  consumption_each_firm = consumption*softmax(prices, gamma=-0.01)
111
111
  demand_each_firm = []
112
112
  for i in range(len(firms_id)):
113
- demand_each_firm.append(int(consumption_each_firm//prices[i]))
114
-
113
+ demand_each_firm.append(int(consumption_each_firm[i]//prices[i]))
115
114
  real_consumption = await self.economy_client.calculate_consumption(firms_id, agent_id, demand_each_firm)
116
115
  node_id = await self.memory.stream.add_economy(description=f"I bought some goods, and spent {real_consumption:.1f} on {intention}")
117
116
  evaluation = {
@@ -299,6 +299,7 @@ class MessageBlock(Block):
299
299
  "success": False,
300
300
  "evaluation": "Could not find target for message",
301
301
  "consumed_time": 5,
302
+ "node_id": result["node_id"],
302
303
  }
303
304
  target = result["target"]
304
305
 
@@ -13,6 +13,13 @@ logger = logging.getLogger("pycityagent")
13
13
 
14
14
 
15
15
  class GovernmentAgent(InstitutionAgent):
16
+ configurable_fields = ["time_diff"]
17
+ default_values = {
18
+ "time_diff": 30 * 24 * 60 * 60,
19
+ }
20
+ fields_description = {
21
+ "time_diff": "Time difference between each forward, day * hour * minute * second",
22
+ }
16
23
  def __init__(
17
24
  self,
18
25
  name: str,
@@ -473,7 +473,7 @@ class EconomyClient:
473
473
  )
474
474
  log["consumption"] = time.time() - start_time
475
475
  self._log_list.append(log)
476
- return (int(response.remain_inventory), list(response.updated_currencies))
476
+ return response.actual_consumption
477
477
 
478
478
  async def calculate_interest(self, org_id: int, agent_ids: list[int]):
479
479
  """
@@ -49,6 +49,7 @@ class AgentGroup:
49
49
  logging_level: int,
50
50
  agent_config_file: Optional[dict[type[Agent], str]] = None,
51
51
  environment: Optional[dict[str, str]] = None,
52
+ llm_semaphore: int = 200,
52
53
  ):
53
54
  """
54
55
  Represents a group of agents that can be deployed in a Ray distributed environment.
@@ -140,7 +141,7 @@ class AgentGroup:
140
141
  llmConfig = LLMConfig(config["llm_request"])
141
142
  logger.info(f"-----Creating LLM client in AgentGroup {self._uuid} ...")
142
143
  self.llm = LLM(llmConfig)
143
- self.llm.set_semaphore(200)
144
+ self.llm.set_semaphore(llm_semaphore)
144
145
 
145
146
  # prepare Simulator
146
147
  logger.info(f"-----Creating Simulator in AgentGroup {self._uuid} ...")
@@ -253,7 +253,8 @@ class AgentSimulation:
253
253
  """Directly run from config file
254
254
  Basic config file should contain:
255
255
  - simulation_config: file_path
256
- - enable_institution: bool, default is True
256
+ - enable_institution: Optional[bool], default is True
257
+ - llm_semaphore: Optional[int], default is 200
257
258
  - agent_config:
258
259
  - agent_config_file: Optional[dict[type[Agent], str]]
259
260
  - memory_config_init_func: Optional[Callable]
@@ -268,7 +269,7 @@ class AgentSimulation:
268
269
  - number_of_bank: required, int
269
270
  - number_of_nbs: required, int
270
271
  - environment: Optional[dict[str, str]]
271
- - default: {'weather': 'The weather is normal', 'crime': 'The crime rate is low', 'pollution': 'The pollution level is low', 'temperature': 'The temperature is normal'}
272
+ - default: {'weather': 'The weather is normal', 'crime': 'The crime rate is low', 'pollution': 'The pollution level is low', 'temperature': 'The temperature is normal', 'day': 'Workday'}
272
273
  - workflow:
273
274
  - list[Step]
274
275
  - Step:
@@ -370,6 +371,7 @@ class AgentSimulation:
370
371
  ),
371
372
  **_message_intercept_kwargs,
372
373
  environment=environment,
374
+ llm_semaphore=config.get("llm_semaphore", 200),
373
375
  )
374
376
  logger.info("Running Init Functions...")
375
377
  for init_func in config["agent_config"].get(
@@ -406,6 +408,7 @@ class AgentSimulation:
406
408
  await step["func"](simulation)
407
409
  logger.info("Simulation finished")
408
410
  return llm_log_lists, mqtt_log_lists, simulator_log_lists
411
+
409
412
  @property
410
413
  def enable_avro(
411
414
  self,
@@ -533,7 +536,8 @@ class AgentSimulation:
533
536
  embedding_model: Embeddings = SimpleEmbedding(),
534
537
  memory_config_init_func: Optional[Callable] = None,
535
538
  memory_config_func: Optional[dict[type[Agent], Callable]] = None,
536
- environment: Optional[dict[str, str]] = None,
539
+ environment: dict[str, str] = {},
540
+ llm_semaphore: int = 200,
537
541
  ) -> None:
538
542
  """
539
543
  Initialize agents within the simulation.
@@ -750,6 +754,7 @@ class AgentSimulation:
750
754
  self.logging_level,
751
755
  config_file,
752
756
  environment,
757
+ llm_semaphore,
753
758
  )
754
759
  creation_tasks.append((group_name, group))
755
760
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycityagent
3
- Version: 2.0.0a67
3
+ Version: 2.0.0a69
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
@@ -1,16 +1,10 @@
1
- pycityagent-2.0.0a67.dist-info/RECORD,,
2
- pycityagent-2.0.0a67.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
3
- pycityagent-2.0.0a67.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
4
- pycityagent-2.0.0a67.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
5
- pycityagent-2.0.0a67.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
6
- pycityagent-2.0.0a67.dist-info/METADATA,sha256=c4r6nC0hBaQ9ux_-fHHvugj-ReCAlqoKDbWew9PE1f8,9110
7
1
  pycityagent/pycityagent-sim,sha256=7AF-sHfnUfVBbiBMOWc11C_5xc9rfEip9lg_7vUieUU,35884466
8
2
  pycityagent/__init__.py,sha256=PUKWTXc-xdMG7px8oTNclodsILUgypANj2Z647sY63k,808
9
3
  pycityagent/pycityagent-ui,sha256=Ur95yZygIaZ5l_CDqP9394M5GQ66iV5PkcNPYFWqzvk,41225346
10
4
  pycityagent/metrics/mlflow_client.py,sha256=-iyh4BPVnBkluhmfucUzibCUnBX2iftkz4tVJJVxwHw,6958
11
5
  pycityagent/metrics/__init__.py,sha256=X08PaBbGVAd7_PRGLREXWxaqm7nS82WBQpD1zvQzcqc,128
12
6
  pycityagent/economy/__init__.py,sha256=aonY4WHnx-6EGJ4WKrx4S-2jAkYNLtqUA04jp6q8B7w,75
13
- pycityagent/economy/econ_client.py,sha256=9kzGMhzoTsOXzyv6vBPscc7LbU3gvN5yiuofMUBOgvE,24797
7
+ pycityagent/economy/econ_client.py,sha256=FUE-7Kxpa3u41eH_4Xye7IYquk1i25Hfv8Smq0nR1-o,24757
14
8
  pycityagent/tools/__init__.py,sha256=y7sMVMHf0AbivlczM2h-kr7mkgXK-WAx3S9BXLXkWvw,235
15
9
  pycityagent/tools/tool.py,sha256=-HZvKeq4gFMo2wJPk6vcr8EdXubM7kA0qC82zv_yS-s,9011
16
10
  pycityagent/llm/llmconfig.py,sha256=6AqCMV4B_JqBD2mb98bLGzpUdlOCnziQKae-Hhxxp-E,469
@@ -27,9 +21,9 @@ pycityagent/memory/utils.py,sha256=oJWLdPeJy_jcdKcDTo9JAH9kDZhqjoQhhv_zT9qWC0w,8
27
21
  pycityagent/memory/const.py,sha256=nFmjvt-8FEB0hc0glOH3lliqJhkhf3D_NKxWI0pf6TY,936
28
22
  pycityagent/memory/faiss_query.py,sha256=KPeyzIjD0dzkxr-TlOeCiIlkdh1WAyyipCAXUEt97Lk,17350
29
23
  pycityagent/memory/state.py,sha256=JFCBuK1AS-HqscvdGS9ATF9AUU8t29_2leDY_6iO2_4,5158
30
- pycityagent/simulation/simulation.py,sha256=WlCs76fvLdZNzmAJvAsKdXiTH7eyvVmqOG9xK-OhQWk,47719
24
+ pycityagent/simulation/simulation.py,sha256=U0Cptnn4kahp6xvDfo1g3NkXat9a1GcgXizoxszQr2c,47920
31
25
  pycityagent/simulation/__init__.py,sha256=u1WpgwVxPboXWMxrUQKMXJNmTKQYAeCaqZv9HmSxESY,118
32
- pycityagent/simulation/agentgroup.py,sha256=TlZekAZBjJsch2ZlvDWgRNyFmyc6kwzd_S550s2Lflw,36796
26
+ pycityagent/simulation/agentgroup.py,sha256=5oJwMqkvWoB_tt0k14YtXY0NqesymatXlsgtJDiUvW0,36840
33
27
  pycityagent/simulation/storage/pg.py,sha256=xRshSOGttW-p0re0fNBOjOpb-nQ5msIE2LsdT79_E_Y,8425
34
28
  pycityagent/message/message_interceptor.py,sha256=QWuTUqi1Cu214fhFs0f78tD2zflMnb6zEAGB4RutXxs,17736
35
29
  pycityagent/message/__init__.py,sha256=f5QH7DKPqEAMyfSlBMnl3uouOKlsoel909STlIe7nUk,276
@@ -81,13 +75,13 @@ pycityagent/cityagent/nbsagent.py,sha256=2021QjPm2JFhDJ0KKNpEZwtTT8GaGyj2zf6KCKH
81
75
  pycityagent/cityagent/initial.py,sha256=a8ed-vvagYw8tJY-uzYm_sAja2545QRAEa58Tp4DHck,6130
82
76
  pycityagent/cityagent/societyagent.py,sha256=2WSXh-eElgigXfDHOh9KoDU2KCmIatwD2D57cZlh0Fs,20253
83
77
  pycityagent/cityagent/message_intercept.py,sha256=dyT1G-nMxKb2prhgtyFFHFz593qBrkk5DnHsHvG1OIc,4418
84
- pycityagent/cityagent/governmentagent.py,sha256=YoydTQ-LMOF5ZbisxG4vQFaFT9ZS0DzDjb3hQg87YzM,2830
78
+ pycityagent/cityagent/governmentagent.py,sha256=XIyggG83FWUTZdOuoqc6ClCP3hhfkxNmtYRu9TFo0dU,3063
85
79
  pycityagent/cityagent/blocks/dispatcher.py,sha256=U5BPeUrjrTyDaznYfT6YUJIW8vfKVRDF4EO0oOn6Td4,2886
86
80
  pycityagent/cityagent/blocks/needs_block.py,sha256=LwoH-4WcAF5L8IOW2ytf51QeIghq9D9KspQ92s5k4Nk,15897
87
81
  pycityagent/cityagent/blocks/cognition_block.py,sha256=5QWhX2vg1VqYYzm-qBITBhVntaaetePQoa7OqvmXJug,15170
88
- pycityagent/cityagent/blocks/social_block.py,sha256=QwmfVYa0Q0anMTYsJe8IxMRecJCNEpCuTsm9bo27eEM,15439
82
+ pycityagent/cityagent/blocks/social_block.py,sha256=eedOlwRTGI47QFELYmfe2a_aj0GuHJweSyDxA6AYXcU,15493
89
83
  pycityagent/cityagent/blocks/__init__.py,sha256=h6si6WBcVVuglIskKQKA8Cxtf_VKen1sNPqOFKI311Q,420
90
- pycityagent/cityagent/blocks/economy_block.py,sha256=CCF2xPxwAiMy0PhFis11_tjH0NMYwSnbUx9VUNfIbGg,19061
84
+ pycityagent/cityagent/blocks/economy_block.py,sha256=zQzZ_A-VrvCNuGu_SdIKr0PAnmUAvOcLBM7eWkN0n9g,19063
91
85
  pycityagent/cityagent/blocks/utils.py,sha256=uu4iQOYKwIT87AqbT5KT4W8p_UI_dZfuXkyxWto_EQ0,2097
92
86
  pycityagent/cityagent/blocks/other_block.py,sha256=LdtL6248xvMvvRQx6NvdlJrWWZFu8Xusjxb9yEh1M0k,4365
93
87
  pycityagent/cityagent/blocks/plan_block.py,sha256=LcmG7d9oMezq9TiEerFJyUZytZRg5Zf03B7m6aV7HCI,11465
@@ -95,3 +89,9 @@ pycityagent/cityagent/blocks/mobility_block.py,sha256=YmKhJW_srC6b6n_LvJujSO-eB-
95
89
  pycityagent/survey/models.py,sha256=g3xni4GcA1Py3vlGt6z4ltutjgQ4G0uINYAM8vKRJAw,5225
96
90
  pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
97
91
  pycityagent/survey/manager.py,sha256=tHkdeq4lTfAHwvgf4-udsXri0z2l6E00rEbvwl7SqRs,3439
92
+ pycityagent-2.0.0a69.dist-info/RECORD,,
93
+ pycityagent-2.0.0a69.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
94
+ pycityagent-2.0.0a69.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
95
+ pycityagent-2.0.0a69.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
96
+ pycityagent-2.0.0a69.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
97
+ pycityagent-2.0.0a69.dist-info/METADATA,sha256=CAOz85QkgBy69X6TCaLlZt32O_jH8bvIi7hZMzAnyk4,9110