pycityagent 2.0.0a82__cp39-cp39-macosx_11_0_arm64.whl → 2.0.0a83__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.
@@ -163,6 +163,22 @@ class EconomyBlock(Block):
163
163
 
164
164
  class MonthPlanBlock(Block):
165
165
  """Monthly Planning"""
166
+ configurable_fields = [
167
+ "UBI",
168
+ "num_labor_hours",
169
+ "productivity_per_labor",
170
+ ]
171
+ default_values = {
172
+ "UBI": 0,
173
+ "num_labor_hours": 168,
174
+ "productivity_per_labor": 1,
175
+ }
176
+ fields_description = {
177
+ "UBI": "Universal Basic Income",
178
+ "num_labor_hours": "Number of labor hours per month",
179
+ "productivity_per_labor": "Productivity per labor hour",
180
+ }
181
+
166
182
  def __init__(self, llm: LLM, memory: Memory, simulator: Simulator, economy_client: EconomyClient):
167
183
  super().__init__("MonthPlanBlock", llm=llm, memory=memory, simulator=simulator)
168
184
  self.economy_client = economy_client
@@ -170,6 +186,12 @@ class MonthPlanBlock(Block):
170
186
  self.last_time_trigger = None
171
187
  self.time_diff = 30 * 24 * 60 * 60
172
188
  self.forward_times = 0
189
+
190
+ # configurable fields
191
+ self.UBI = 0
192
+ self.num_labor_hours = 168
193
+ self.productivity_per_labor = 1
194
+
173
195
 
174
196
  async def month_trigger(self):
175
197
  now_time = await self.simulator.get_time()
@@ -216,8 +238,8 @@ class MonthPlanBlock(Block):
216
238
  Besides, your consumption was ${consumption:.2f}.
217
239
  '''
218
240
  tax_prompt = f'''Your tax deduction amounted to ${tax_paid:.2f}, and the government uses the tax revenue to provide social services to all citizens.'''
219
- if UBI and self.forward_times >= 96:
220
- tax_prompt = f'{tax_prompt} Specifically, the government directly provides ${UBI} per capita in each month.'
241
+ if self.UBI and self.forward_times >= 96:
242
+ tax_prompt = f'{tax_prompt} Specifically, the government directly provides ${self.UBI} per capita in each month.'
221
243
  price_prompt = f'''Meanwhile, in the consumption market, the average price of essential goods is now at ${price:.2f}.'''
222
244
  job_prompt = prettify_document(job_prompt)
223
245
  obs_prompt = f'''
@@ -250,18 +272,18 @@ class MonthPlanBlock(Block):
250
272
  work_skill = await self.economy_client.get(agent_id, 'skill')
251
273
  work_propensity = await self.memory.status.get('work_propensity')
252
274
  consumption_propensity = await self.memory.status.get('consumption_propensity')
253
- work_hours = work_propensity * num_labor_hours
275
+ work_hours = work_propensity * self.num_labor_hours
254
276
  income = await self.economy_client.get(agent_id, 'income')
255
277
  income += work_hours * work_skill
256
278
 
257
279
  wealth = await self.economy_client.get(agent_id, 'currency')
258
280
  wealth += work_hours * work_skill
259
281
  await self.economy_client.update(agent_id, 'currency', wealth)
260
- await self.economy_client.add_delta_value(firm_id, 'inventory', int(work_hours*productivity_per_labor))
282
+ await self.economy_client.add_delta_value(firm_id, 'inventory', int(work_hours*self.productivity_per_labor))
261
283
 
262
- if UBI and self.forward_times >= 96:
263
- income += UBI
264
- wealth += UBI
284
+ if self.UBI and self.forward_times >= 96:
285
+ income += self.UBI
286
+ wealth += self.UBI
265
287
 
266
288
  await self.memory.status.update('to_consumption_currency', consumption_propensity*wealth)
267
289
 
@@ -318,7 +340,7 @@ class MonthPlanBlock(Block):
318
340
  except:
319
341
  self.llm_error += 1
320
342
 
321
- if 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:
322
344
  obs_prompt = f'''
323
345
  {problem_prompt} {job_prompt} {consumption_prompt} {tax_prompt} {price_prompt}
324
346
  Your current savings account balance is ${wealth:.2f}. Interest rates, as set by your bank, stand at {interest_rate*100:.2f}%.
@@ -23,19 +23,6 @@ Please return the result in JSON format (Do not return any other text):
23
23
  }}
24
24
  """
25
25
 
26
- num_labor_hours = 168
27
- productivity_per_labor = 1
28
- max_price_inflation = 0.1
29
- max_wage_inflation = 0.05
30
- natural_interest_rate = 0.01
31
- target_inflation = 0.02
32
- natural_unemployment_rate = 0.04
33
- inflation_coeff, unemployment_coeff = 0.5, 0.5
34
- tao = 1
35
- period = 3
36
- UBI = 0
37
-
38
-
39
26
  def prettify_document(document: str) -> str:
40
27
  # Remove sequences of whitespace characters (including newlines)
41
28
  cleaned = re.sub(r"\s+", " ", document).strip()
@@ -22,7 +22,7 @@ logger = logging.getLogger("pycityagent")
22
22
  class PlanAndActionBlock(Block):
23
23
  """Active workflow based on needs model and plan behavior model"""
24
24
 
25
- longTermDecisionBlock: MonthPlanBlock
25
+ monthPlanBlock: MonthPlanBlock
26
26
  needsBlock: NeedsBlock
27
27
  planBlock: PlanBlock
28
28
  mobilityBlock: MobilityBlock
@@ -50,7 +50,7 @@ class PlanAndActionBlock(Block):
50
50
  self.enable_social = enable_social
51
51
  self.enable_economy = enable_economy
52
52
  self.enable_cognition = enable_cognition
53
- self.longTermDecisionBlock = MonthPlanBlock(
53
+ self.monthPlanBlock = MonthPlanBlock(
54
54
  llm=llm, memory=memory, simulator=simulator, economy_client=economy_client
55
55
  )
56
56
  self.needsBlock = NeedsBlock(llm=llm, memory=memory, simulator=simulator)
@@ -141,7 +141,7 @@ class PlanAndActionBlock(Block):
141
141
 
142
142
  async def forward(self):
143
143
  # Long-term decision
144
- await self.longTermDecisionBlock.forward()
144
+ await self.monthPlanBlock.forward()
145
145
 
146
146
  # update needs
147
147
  await self.needsBlock.forward()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pycityagent
3
- Version: 2.0.0a82
3
+ Version: 2.0.0a83
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,3 +1,9 @@
1
+ pycityagent-2.0.0a83.dist-info/RECORD,,
2
+ pycityagent-2.0.0a83.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
3
+ pycityagent-2.0.0a83.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
4
+ pycityagent-2.0.0a83.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
5
+ pycityagent-2.0.0a83.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
6
+ pycityagent-2.0.0a83.dist-info/METADATA,sha256=XmwytGxXKWAS-M9uFrfJ3Csu1jkQhXN1Po0ZBUyc5nI,9110
1
7
  pycityagent/pycityagent-sim,sha256=MmiGNhZgGjXYLJ2EYTGMhfGAZU8TnU7ORsJ6kdtzjDs,36973378
2
8
  pycityagent/__init__.py,sha256=PUKWTXc-xdMG7px8oTNclodsILUgypANj2Z647sY63k,808
3
9
  pycityagent/pycityagent-ui,sha256=Ur95yZygIaZ5l_CDqP9394M5GQ66iV5PkcNPYFWqzvk,41225346
@@ -73,7 +79,7 @@ pycityagent/cityagent/__init__.py,sha256=gcBQ-a50XegFtjigQ7xDXRBZrywBKqifiQFSRnE
73
79
  pycityagent/cityagent/firmagent.py,sha256=vZr7kdjnxcCZ5qX7hmUIYuQQWd44GcRPbdi76WGSFy4,3760
74
80
  pycityagent/cityagent/nbsagent.py,sha256=knSaQbCNkWi7bZjwwEr_hTKj44_q67eHif6HI3W9i1M,4558
75
81
  pycityagent/cityagent/initial.py,sha256=0DSOWnVVknMw6xoJWfdZUFBH3yti8y800wnkXXCocxY,6194
76
- pycityagent/cityagent/societyagent.py,sha256=dY8coUMtrTrcATCYDdI0MvVt42YXSyP-ZWi24H9xg7o,20090
82
+ pycityagent/cityagent/societyagent.py,sha256=1c6k3RgxQ7AAYCiBXwiSZLDkCDMgCrBzNF6vi6lK2Yc,20069
77
83
  pycityagent/cityagent/message_intercept.py,sha256=dyT1G-nMxKb2prhgtyFFHFz593qBrkk5DnHsHvG1OIc,4418
78
84
  pycityagent/cityagent/governmentagent.py,sha256=XIyggG83FWUTZdOuoqc6ClCP3hhfkxNmtYRu9TFo0dU,3063
79
85
  pycityagent/cityagent/blocks/dispatcher.py,sha256=U5BPeUrjrTyDaznYfT6YUJIW8vfKVRDF4EO0oOn6Td4,2886
@@ -81,17 +87,11 @@ pycityagent/cityagent/blocks/needs_block.py,sha256=NYKrGDoYCuXoupMNMuSNhx4Ci1paC
81
87
  pycityagent/cityagent/blocks/cognition_block.py,sha256=yzjB0D_95vytpa5xiVdmTSpGp8H9HXcjWzzFN0OpP0k,15398
82
88
  pycityagent/cityagent/blocks/social_block.py,sha256=eedOlwRTGI47QFELYmfe2a_aj0GuHJweSyDxA6AYXcU,15493
83
89
  pycityagent/cityagent/blocks/__init__.py,sha256=h6si6WBcVVuglIskKQKA8Cxtf_VKen1sNPqOFKI311Q,420
84
- pycityagent/cityagent/blocks/economy_block.py,sha256=1yHUdCSAzvvhdGFzMfSM_wtbW_3D6YeYSNlVV3yQqsA,19083
85
- pycityagent/cityagent/blocks/utils.py,sha256=BVOTtZC8dJIc0eGGNmL0LQ_WnMfXr54q1gyrrDwRn-Y,2079
90
+ pycityagent/cityagent/blocks/economy_block.py,sha256=qu7OlQvFIL9m6jv7IHLXBQVHjC8noSuPB6Gd31Thjvc,19679
91
+ pycityagent/cityagent/blocks/utils.py,sha256=K--6odjUDUu9YrwrHPaiPIHryo7m_MBmcBqDAy3cV5M,1816
86
92
  pycityagent/cityagent/blocks/other_block.py,sha256=LdtL6248xvMvvRQx6NvdlJrWWZFu8Xusjxb9yEh1M0k,4365
87
93
  pycityagent/cityagent/blocks/plan_block.py,sha256=A5DvtXIy98MZkRGUQmp26grNI5i0BVbl3aEM_Ebd6Z4,11271
88
94
  pycityagent/cityagent/blocks/mobility_block.py,sha256=qkRiV0nkGOUUoo9lGIjAFE_Hl0kiyMev12-Zm7JyV7o,15089
89
95
  pycityagent/survey/models.py,sha256=g3xni4GcA1Py3vlGt6z4ltutjgQ4G0uINYAM8vKRJAw,5225
90
96
  pycityagent/survey/__init__.py,sha256=rxwou8U9KeFSP7rMzXtmtp2fVFZxK4Trzi-psx9LPIs,153
91
97
  pycityagent/survey/manager.py,sha256=tHkdeq4lTfAHwvgf4-udsXri0z2l6E00rEbvwl7SqRs,3439
92
- pycityagent-2.0.0a82.dist-info/RECORD,,
93
- pycityagent-2.0.0a82.dist-info/LICENSE,sha256=n2HPXiupinpyHMnIkbCf3OTYd3KMqbmldu1e7av0CAU,1084
94
- pycityagent-2.0.0a82.dist-info/WHEEL,sha256=md3JO_ifs5j508p3TDNMgtQVtnQblpGEt_Wo4W56l8Y,107
95
- pycityagent-2.0.0a82.dist-info/entry_points.txt,sha256=BZcne49AAIFv-hawxGnPbblea7X3MtAtoPyDX8L4OC4,132
96
- pycityagent-2.0.0a82.dist-info/top_level.txt,sha256=yOmeu6cSXmiUtScu53a3s0p7BGtLMaV0aff83EHCTic,43
97
- pycityagent-2.0.0a82.dist-info/METADATA,sha256=a48d_5hO9dLaPc6fmDJ4N-T83VWIwdmEJQFGMk1rlxw,9110