pycityagent 1.1.0__tar.gz → 1.1.2__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.
Files changed (63) hide show
  1. {pycityagent-1.1.0 → pycityagent-1.1.2}/PKG-INFO +6 -4
  2. {pycityagent-1.1.0 → pycityagent-1.1.2}/README.md +5 -3
  3. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/sence.py +34 -7
  4. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/urbanllm/urbanllm.py +5 -4
  5. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent.egg-info/PKG-INFO +6 -4
  6. {pycityagent-1.1.0 → pycityagent-1.1.2}/LICENSE +0 -0
  7. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/__init__.py +0 -0
  8. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/__init__.py +0 -0
  9. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/ac.py +0 -0
  10. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/action.py +0 -0
  11. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/action_stream.py +0 -0
  12. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/citizen_actions/controled.py +0 -0
  13. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/citizen_actions/converse.py +0 -0
  14. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/citizen_actions/idle.py +0 -0
  15. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/citizen_actions/shop.py +0 -0
  16. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/citizen_actions/trip.py +0 -0
  17. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/controled.py +0 -0
  18. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/converse.py +0 -0
  19. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/hub_actions.py +0 -0
  20. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/idle.py +0 -0
  21. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/shop.py +0 -0
  22. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/sim_actions.py +0 -0
  23. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/ac/trip.py +0 -0
  24. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/agent.py +0 -0
  25. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/agent_citizen.py +0 -0
  26. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/agent_func.py +0 -0
  27. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/__init__.py +0 -0
  28. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/brain.py +0 -0
  29. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/brainfc.py +0 -0
  30. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/memory.py +0 -0
  31. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/persistence/__init__.py +0 -0
  32. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/persistence/social.py +0 -0
  33. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/persistence/spatial.py +0 -0
  34. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/reason/__init__.py +0 -0
  35. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/reason/shop.py +0 -0
  36. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/reason/social.py +0 -0
  37. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/reason/trip.py +0 -0
  38. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/reason/user.py +0 -0
  39. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/retrive/__init__.py +0 -0
  40. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/retrive/social.py +0 -0
  41. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/scheduler.py +0 -0
  42. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/brain/static.py +0 -0
  43. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/__init__.py +0 -0
  44. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/cc.py +0 -0
  45. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/conve.py +0 -0
  46. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/idle.py +0 -0
  47. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/shop.py +0 -0
  48. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/trip.py +0 -0
  49. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/cc/user.py +0 -0
  50. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/hubconnector/__init__.py +0 -0
  51. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/hubconnector/hubconnector.py +0 -0
  52. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/image/__init__.py +0 -0
  53. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/image/image.py +0 -0
  54. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/simulator.py +0 -0
  55. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/st/__init__.py +0 -0
  56. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/st/st.py +0 -0
  57. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent/urbanllm/__init__.py +0 -0
  58. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent.egg-info/SOURCES.txt +0 -0
  59. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent.egg-info/dependency_links.txt +0 -0
  60. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent.egg-info/requires.txt +0 -0
  61. {pycityagent-1.1.0 → pycityagent-1.1.2}/pycityagent.egg-info/top_level.txt +0 -0
  62. {pycityagent-1.1.0 → pycityagent-1.1.2}/pyproject.toml +0 -0
  63. {pycityagent-1.1.0 → pycityagent-1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycityagent
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: LLM-based城市模拟器agent构建库
5
5
  Author-email: Yuwei Yan <pinkgranite86@gmail.com>
6
6
  License: MIT License
@@ -60,7 +60,7 @@ Requires-Dist: transitions>=0.9.0
60
60
  - ![framwork](./static/framework.png)
61
61
 
62
62
  ### Workflow of CityAgent
63
- - ![workflow](./static/workflow.png)
63
+ - ![workflow](./static/workflow_1.png)
64
64
 
65
65
  ## Hands On - By An Easy Demo
66
66
  ### Apply for your App
@@ -74,9 +74,10 @@ Requires-Dist: transitions>=0.9.0
74
74
  ```yaml
75
75
  llm_request:
76
76
  text_request:
77
- request_type: qwen
77
+ request_type: openai / qwen
78
78
  api_key: xxx
79
79
  model: xxx
80
+ http_client: xxx (if you use opanai and want to use your own backend LLM model)
80
81
  img_understand_request:
81
82
  request_type: qwen
82
83
  api_key: xxx
@@ -111,7 +112,8 @@ apphub_request:
111
112
  - As you can see, the whole CityAgent is based on the LLM, by now, there are three different parts of config items: **text_request**, **img_understand_request** and **img_generate_request**
112
113
  - By now, we support [**qwen**](https://tongyi.aliyun.com/) and [**openai**](https://openai.com/)
113
114
  - `Notice: Our environments are basically conducted with qwen. If you prefer to use openai, then you may encounter hardships. AND fell free to issue us.`
114
- - Get your **api_key** and chooce your **model**s
115
+ - Get your **api_key** and chooce your **model**
116
+ - If you want to use your backend models, set the **http_client** (only available when using **openai**)
115
117
 
116
118
  #### CITYSIM_REQUEST
117
119
  - Most of the configuration options in this part are determined, such as **simulator.server**, **map_request.mongo_coll**, **route_request.server**
@@ -13,7 +13,7 @@
13
13
  - ![framwork](./static/framework.png)
14
14
 
15
15
  ### Workflow of CityAgent
16
- - ![workflow](./static/workflow.png)
16
+ - ![workflow](./static/workflow_1.png)
17
17
 
18
18
  ## Hands On - By An Easy Demo
19
19
  ### Apply for your App
@@ -27,9 +27,10 @@
27
27
  ```yaml
28
28
  llm_request:
29
29
  text_request:
30
- request_type: qwen
30
+ request_type: openai / qwen
31
31
  api_key: xxx
32
32
  model: xxx
33
+ http_client: xxx (if you use opanai and want to use your own backend LLM model)
33
34
  img_understand_request:
34
35
  request_type: qwen
35
36
  api_key: xxx
@@ -64,7 +65,8 @@ apphub_request:
64
65
  - As you can see, the whole CityAgent is based on the LLM, by now, there are three different parts of config items: **text_request**, **img_understand_request** and **img_generate_request**
65
66
  - By now, we support [**qwen**](https://tongyi.aliyun.com/) and [**openai**](https://openai.com/)
66
67
  - `Notice: Our environments are basically conducted with qwen. If you prefer to use openai, then you may encounter hardships. AND fell free to issue us.`
67
- - Get your **api_key** and chooce your **model**s
68
+ - Get your **api_key** and chooce your **model**
69
+ - If you want to use your backend models, set the **http_client** (only available when using **openai**)
68
70
 
69
71
  #### CITYSIM_REQUEST
70
72
  - Most of the configuration options in this part are determined, such as **simulator.server**, **map_request.mongo_coll**, **route_request.server**
@@ -297,7 +297,8 @@ class Sence(BrainFunction):
297
297
  - List[dict]: 可达位置列表
298
298
  - lane_id (int)
299
299
  - s (float)
300
- - longlat (Tuple[float, float]): [longitude, latitude]
300
+ - xy (Tuple[float, float]): (x, y)
301
+ - longlat (Tuple[float, float]): (longitude, latitude)
301
302
  - type (str): 'driving' / 'walking' / 'unspecified'
302
303
  '''
303
304
  radius_ = self._sence_radius
@@ -318,6 +319,7 @@ class Sence(BrainFunction):
318
319
  positions.append({
319
320
  'lane_id': driving_positions[i]['lane_id'],
320
321
  's': driving_positions[i]['s'],
322
+ 'xy': (driving_gates[i]['x'], driving_gates[i]['y']),
321
323
  'longlat': longlat,
322
324
  'type': 'driving'
323
325
  })
@@ -326,6 +328,7 @@ class Sence(BrainFunction):
326
328
  positions.append({
327
329
  'lane_id': walking_positions[i]['lane_id'],
328
330
  's': walking_positions[i]['s'],
331
+ 'xy': (walking_gates[i]['x'], walking_gates[i]['y']),
329
332
  'longlat': longlat,
330
333
  'type': 'walking'
331
334
  })
@@ -343,7 +346,11 @@ class Sence(BrainFunction):
343
346
  x, y = get_xy_in_lane(nodes, tmp_s)
344
347
  longlat = self._agent._simulator.map.xy2lnglat(x=x, y=y)
345
348
  type = copy.deepcopy(self._lane_type_mapping.get(lane['type'], 'unspecified'))
346
- positions += [{'lane_id': lane_id, 's': tmp_s, 'longlat': longlat, 'type': type}]
349
+ positions += [{'lane_id': lane_id,
350
+ 's': tmp_s,
351
+ 'xy': (x, y),
352
+ 'longlat': longlat,
353
+ 'type': type}]
347
354
 
348
355
  # 2. 前驱道路
349
356
  pre_lanes = lane['predecessors']
@@ -356,7 +363,11 @@ class Sence(BrainFunction):
356
363
  x, y = get_xy_in_lane(pre_lane_nodes, tmp_s, 'back')
357
364
  longlat = self._agent._simulator.map.xy2lnglat(x=x, y=y)
358
365
  type = self._lane_type_mapping.get(pre_lane_['type'], 'unspecified')
359
- positions += [{'lane_id': pre_lane_id, 's': tmp_s, 'longlat': longlat, 'type': type}]
366
+ positions += [{'lane_id': pre_lane_id,
367
+ 's': tmp_s,
368
+ 'xy': (x, y),
369
+ 'longlat': longlat,
370
+ 'type': type}]
360
371
  elif agent_s == lane['length']:
361
372
  # 处于当前道路的尾部端点位置
362
373
  # 1. 当前道路
@@ -365,7 +376,11 @@ class Sence(BrainFunction):
365
376
  x, y = get_xy_in_lane(nodes, tmp_s, 'back')
366
377
  longlat = self._agent._simulator.map.xy2loglat(x=x, y=y)
367
378
  type = self._lane_type_mapping.get(lane['type'], 'unspecified')
368
- positions += [{'lane_id': lane_id, 's': tmp_s, 'longlat': longlat, 'type': type}]
379
+ positions += [{'lane_id': lane_id,
380
+ 's': tmp_s,
381
+ 'xy': (x, y),
382
+ 'longlat': longlat,
383
+ 'type': type}]
369
384
 
370
385
  # 2. 后继道路
371
386
  suc_lanes = lane['successors']
@@ -378,7 +393,11 @@ class Sence(BrainFunction):
378
393
  x, y = get_xy_in_lane(suc_lane_nodes, tmp_s)
379
394
  longlat = self._agent._simulator.map.xy2loglat(x=x, y=y)
380
395
  type = self._lane_type_mapping.get(lane['type'], 'unspecified')
381
- positions += [{'lane_id': suc_lane_id, 's': tmp_s, 'longlat': longlat, 'type': type}]
396
+ positions += [{'lane_id': suc_lane_id,
397
+ 's': tmp_s,
398
+ 'xy': (x, y),
399
+ 'longlat': longlat,
400
+ 'type': type}]
382
401
  else:
383
402
  # 非端点位置
384
403
  neg_s = agent_s - radius_
@@ -386,14 +405,22 @@ class Sence(BrainFunction):
386
405
  x, y = get_xy_in_lane(nodes, neg_s, 'back')
387
406
  longlat = self._agent._simulator.map.xy2loglat(x=x, y=y)
388
407
  type = self._lane_type_mapping.get(lane['type'], 'unspecified')
389
- positions += [{'lans_id': lane_id, 's': neg_s, 'longlat': longlat, 'type': type}]
408
+ positions += [{'lans_id': lane_id,
409
+ 's': neg_s,
410
+ 'xy': (x, y),
411
+ 'longlat': longlat,
412
+ 'type': type}]
390
413
 
391
414
  pos_s = agent_s + radius_
392
415
  pos_s = pos_s if pos_s <= lane['length'] else lane['length']
393
416
  x, y = get_xy_in_lane(nodes, pos_s)
394
417
  longlat = self._agent._simulator.map.xy2loglat(x=x, y=y)
395
418
  type = self._lane_type_mapping.get(lane['type'], 'unspecified')
396
- positions += [{'lans_id': lane_id, 's': neg_s, 'longlat': longlat, 'type': type}]
419
+ positions += [{'lans_id': lane_id,
420
+ 's': neg_s,
421
+ 'xy': (x, y),
422
+ 'longlat': longlat,
423
+ 'type': type}]
397
424
  return positions
398
425
 
399
426
  async def PerceivePoi(self, radius:int=None, category:str=None):
@@ -41,10 +41,12 @@ class UrbanLLM:
41
41
  Returns:
42
42
  - (str): the response content
43
43
  """
44
+ client = None if self.config.text['http_client'] == None else self.config.text['http_client']
44
45
  if self.config.text['request_type'] == 'openai':
45
46
  client = OpenAI(
46
47
  api_key=self.config.text['api_key'],
47
- base_url=self.config.text['api_base']
48
+ base_url=self.config.text['api_base'],
49
+ http_client=client
48
50
  )
49
51
  response = client.chat.completions.create(
50
52
  model=self.config.text['model'],
@@ -53,7 +55,6 @@ class UrbanLLM:
53
55
  )
54
56
  return response.choices[0].message.content
55
57
  elif self.config.text['request_type'] == 'qwen':
56
-
57
58
  response = dashscope.Generation.call(
58
59
  model=self.config.text['model'],
59
60
  api_key=self.config.text['api_key'],
@@ -82,7 +83,7 @@ class UrbanLLM:
82
83
  """
83
84
  ppt = "如何理解这幅图像?"
84
85
  if prompt != None:
85
- ppt += prompt
86
+ ppt = prompt
86
87
  dialog = [{
87
88
  'role': 'user',
88
89
  'content': [
@@ -101,7 +102,7 @@ class UrbanLLM:
101
102
  print(response.code) # The error code.
102
103
  return "Error"
103
104
 
104
- def img_generate(self, prompt, size:str='512*512', quantity:int = 1):
105
+ def img_generate(self, prompt:str, size:str='512*512', quantity:int = 1):
105
106
  """
106
107
  图像生成
107
108
  Image generation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycityagent
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: LLM-based城市模拟器agent构建库
5
5
  Author-email: Yuwei Yan <pinkgranite86@gmail.com>
6
6
  License: MIT License
@@ -60,7 +60,7 @@ Requires-Dist: transitions>=0.9.0
60
60
  - ![framwork](./static/framework.png)
61
61
 
62
62
  ### Workflow of CityAgent
63
- - ![workflow](./static/workflow.png)
63
+ - ![workflow](./static/workflow_1.png)
64
64
 
65
65
  ## Hands On - By An Easy Demo
66
66
  ### Apply for your App
@@ -74,9 +74,10 @@ Requires-Dist: transitions>=0.9.0
74
74
  ```yaml
75
75
  llm_request:
76
76
  text_request:
77
- request_type: qwen
77
+ request_type: openai / qwen
78
78
  api_key: xxx
79
79
  model: xxx
80
+ http_client: xxx (if you use opanai and want to use your own backend LLM model)
80
81
  img_understand_request:
81
82
  request_type: qwen
82
83
  api_key: xxx
@@ -111,7 +112,8 @@ apphub_request:
111
112
  - As you can see, the whole CityAgent is based on the LLM, by now, there are three different parts of config items: **text_request**, **img_understand_request** and **img_generate_request**
112
113
  - By now, we support [**qwen**](https://tongyi.aliyun.com/) and [**openai**](https://openai.com/)
113
114
  - `Notice: Our environments are basically conducted with qwen. If you prefer to use openai, then you may encounter hardships. AND fell free to issue us.`
114
- - Get your **api_key** and chooce your **model**s
115
+ - Get your **api_key** and chooce your **model**
116
+ - If you want to use your backend models, set the **http_client** (only available when using **openai**)
115
117
 
116
118
  #### CITYSIM_REQUEST
117
119
  - Most of the configuration options in this part are determined, such as **simulator.server**, **map_request.mongo_coll**, **route_request.server**
File without changes
File without changes
File without changes