pycityagent 2.0.0a21__tar.gz → 2.0.0a24__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 (77) hide show
  1. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/PKG-INFO +5 -1
  2. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/__init__.py +2 -1
  3. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/agent.py +18 -4
  4. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/aoi_service.py +2 -1
  5. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/clock_service.py +2 -1
  6. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/economy_services.py +9 -8
  7. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/lane_service.py +6 -5
  8. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/light_service.py +10 -8
  9. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/person_service.py +12 -11
  10. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/road_service.py +3 -2
  11. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/social_service.py +4 -3
  12. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/protobuf.py +6 -4
  13. pycityagent-2.0.0a24/pycityagent/llm/__init__.py +11 -0
  14. pycityagent-2.0.0a24/pycityagent/llm/embeddings.py +231 -0
  15. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/__init__.py +2 -0
  16. pycityagent-2.0.0a24/pycityagent/memory/faiss_query.py +302 -0
  17. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/memory.py +131 -137
  18. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/memory_base.py +7 -6
  19. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/profile.py +7 -6
  20. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/self_define.py +8 -7
  21. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/state.py +7 -6
  22. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/utils.py +2 -1
  23. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/simulation/agentgroup.py +42 -25
  24. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/simulation/simulation.py +9 -1
  25. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/parsers/json_parser.py +3 -3
  26. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/workflow/block.py +2 -1
  27. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pyproject.toml +5 -1
  28. pycityagent-2.0.0a21/pycityagent/llm/__init__.py +0 -6
  29. pycityagent-2.0.0a21/pycityagent/llm/embedding.py +0 -136
  30. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/README.md +0 -0
  31. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/economy/__init__.py +0 -0
  32. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/economy/econ_client.py +0 -0
  33. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/__init__.py +0 -0
  34. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/interact/__init__.py +0 -0
  35. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/interact/interact.py +0 -0
  36. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/message/__init__.py +0 -0
  37. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sence/__init__.py +0 -0
  38. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sence/static.py +0 -0
  39. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sidecar/__init__.py +0 -0
  40. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sidecar/sidecarv2.py +0 -0
  41. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/__init__.py +0 -0
  42. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/client.py +0 -0
  43. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/sim/sim_env.py +0 -0
  44. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/simulator.py +0 -0
  45. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/__init__.py +0 -0
  46. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/base64.py +0 -0
  47. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/const.py +0 -0
  48. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/geojson.py +0 -0
  49. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/grpc.py +0 -0
  50. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/map_utils.py +0 -0
  51. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/environment/utils/port.py +0 -0
  52. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/llm/llm.py +0 -0
  53. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/llm/llmconfig.py +0 -0
  54. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/llm/utils.py +0 -0
  55. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/memory/const.py +0 -0
  56. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/message/__init__.py +0 -0
  57. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/message/messager.py +0 -0
  58. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/metrics/__init__.py +0 -0
  59. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/metrics/mlflow_client.py +0 -0
  60. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/metrics/utils/const.py +0 -0
  61. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/simulation/__init__.py +0 -0
  62. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/simulation/storage/pg.py +0 -0
  63. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/survey/__init__.py +0 -0
  64. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/survey/manager.py +0 -0
  65. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/survey/models.py +0 -0
  66. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/__init__.py +0 -0
  67. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/avro_schema.py +0 -0
  68. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/decorators.py +0 -0
  69. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/parsers/__init__.py +0 -0
  70. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/parsers/code_block_parser.py +0 -0
  71. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/parsers/parser_base.py +0 -0
  72. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/pg_query.py +0 -0
  73. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/utils/survey_util.py +0 -0
  74. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/workflow/__init__.py +0 -0
  75. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/workflow/prompt.py +0 -0
  76. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/workflow/tool.py +0 -0
  77. {pycityagent-2.0.0a21 → pycityagent-2.0.0a24}/pycityagent/workflow/trigger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycityagent
3
- Version: 2.0.0a21
3
+ Version: 2.0.0a24
4
4
  Summary: LLM-based城市环境agent构建库
5
5
  License: MIT
6
6
  Author: Yuwei Yan
@@ -20,10 +20,12 @@ Requires-Dist: aiohttp (==3.10.10)
20
20
  Requires-Dist: aiomqtt (>=2.3.0,<3.0.0)
21
21
  Requires-Dist: citystreetview (==1.2.4)
22
22
  Requires-Dist: dashscope (==1.14.1)
23
+ Requires-Dist: faiss-cpu (>=1.9.0.post1,<2.0.0)
23
24
  Requires-Dist: fastavro (>=1.10.0,<2.0.0)
24
25
  Requires-Dist: geojson (==3.1.0)
25
26
  Requires-Dist: gradio (>=5.7.1,<6.0.0)
26
27
  Requires-Dist: grpcio (==1.67.1)
28
+ Requires-Dist: langchain-community (>=0.3.13,<0.4.0)
27
29
  Requires-Dist: langchain-core (>=0.3.28,<0.4.0)
28
30
  Requires-Dist: matplotlib (==3.8.3)
29
31
  Requires-Dist: mlflow (>=2.19.0,<3.0.0)
@@ -40,6 +42,8 @@ Requires-Dist: pycityproto (>=2.1.5,<3.0.0)
40
42
  Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
41
43
  Requires-Dist: ray (>=2.40.0,<3.0.0)
42
44
  Requires-Dist: sidecar (==0.7.0)
45
+ Requires-Dist: torch (>=2.5.1,<3.0.0)
46
+ Requires-Dist: transformers (>=4.47.1,<5.0.0)
43
47
  Requires-Dist: zhipuai (>=2.1.5.20230904,<3.0.0.0)
44
48
  Description-Content-Type: text/markdown
45
49
 
@@ -5,6 +5,7 @@ Pycityagent: 城市智能体构建框架
5
5
  from .agent import Agent, CitizenAgent, InstitutionAgent
6
6
  from .environment import Simulator
7
7
  import logging
8
+ from .llm import SentenceEmbedding
8
9
 
9
10
  # 创建一个 pycityagent 记录器
10
11
  logger = logging.getLogger("pycityagent")
@@ -19,4 +20,4 @@ if not logger.hasHandlers():
19
20
  handler.setFormatter(formatter)
20
21
  logger.addHandler(handler)
21
22
 
22
- __all__ = ["Agent", "Simulator", "CitizenAgent", "InstitutionAgent"]
23
+ __all__ = ["Agent", "Simulator", "CitizenAgent", "InstitutionAgent","SentenceEmbedding",]
@@ -236,7 +236,15 @@ class Agent(ABC):
236
236
 
237
237
  # 添加记忆上下文
238
238
  if self._memory:
239
- relevant_memories = await self._memory.search(survey_prompt)
239
+ relevant_memories = await self.memory.search(survey_prompt)
240
+
241
+ formatted_results = []
242
+ # for result in top_results:
243
+ # formatted_results.append(
244
+ # f"- [{result['type']}] {result['content']} "
245
+ # f"(相关度: {result['similarity']:.2f})"
246
+ # )
247
+
240
248
  if relevant_memories:
241
249
  dialog.append(
242
250
  {
@@ -458,13 +466,18 @@ class Agent(ABC):
458
466
  topic = f"exps/{self._exp_id}/agents/{to_agent_uuid}/{sub_topic}"
459
467
  await self._messager.send_message(topic, payload)
460
468
 
461
- async def send_message_to_agent(self, to_agent_uuid: str, content: str):
469
+ async def send_message_to_agent(
470
+ self, to_agent_uuid: str, content: str, type: str = "social"
471
+ ):
462
472
  """通过 Messager 发送消息"""
463
473
  if self._messager is None:
464
474
  raise RuntimeError("Messager is not set")
475
+ if type not in ["social", "economy"]:
476
+ logger.warning(f"Invalid message type: {type}, sent from {self._uuid}")
465
477
  payload = {
466
478
  "from": self._uuid,
467
479
  "content": content,
480
+ "type": type,
468
481
  "timestamp": int(datetime.now().timestamp() * 1000),
469
482
  "day": await self.simulator.get_simulator_day(),
470
483
  "t": await self.simulator.get_simulator_second_from_start_of_day(),
@@ -485,11 +498,11 @@ class Agent(ABC):
485
498
  auros.append(_message_dict)
486
499
  pg_list.append((_message_dict, _date_time))
487
500
  # Avro
488
- if self._avro_file is not None:
501
+ if self._avro_file is not None and type == "social":
489
502
  with open(self._avro_file["dialog"], "a+b") as f:
490
503
  fastavro.writer(f, DIALOG_SCHEMA, auros, codec="snappy")
491
504
  # Pg
492
- if self._pgsql_writer is not None:
505
+ if self._pgsql_writer is not None and type == "social":
493
506
  if self._last_asyncio_pg_task is not None:
494
507
  await self._last_asyncio_pg_task
495
508
  _keys = ["id", "day", "t", "type", "speaker", "content", "created_at"]
@@ -595,6 +608,7 @@ class CitizenAgent(Agent):
595
608
  # 防止模拟器还没有到prepare阶段导致get_person出错
596
609
  self._has_bound_to_simulator = True
597
610
  self._agent_id = person_id
611
+ self.memory.set_agent_id(person_id)
598
612
 
599
613
  async def _bind_to_economy(self):
600
614
  if self._economy_client is None:
@@ -1,4 +1,5 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from collections.abc import Awaitable, Coroutine
2
+ from typing import Any, Dict, Union, cast
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
@@ -1,4 +1,5 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from collections.abc import Awaitable, Coroutine
2
+ from typing import Any, Dict, Union, cast
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
@@ -1,4 +1,5 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from typing import Any, cast, Union
2
+ from collections.abc import Awaitable, Coroutine
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
@@ -25,7 +26,7 @@ class EconomyPersonService:
25
26
  self,
26
27
  req: Union[person_service.GetPersonRequest, dict],
27
28
  dict_return: bool = True,
28
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], person_service.GetPersonResponse]]:
29
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], person_service.GetPersonResponse]]:
29
30
  """
30
31
  批量查询人的经济情况(资金、雇佣关系)
31
32
  Query person’s economic situation (funds, employment relationship) in batches
@@ -48,7 +49,7 @@ class EconomyPersonService:
48
49
  req: Union[person_service.UpdatePersonMoneyRequest, dict],
49
50
  dict_return: bool = True,
50
51
  ) -> Coroutine[
51
- Any, Any, Union[Dict[str, Any], person_service.UpdatePersonMoneyResponse]
52
+ Any, Any, Union[dict[str, Any], person_service.UpdatePersonMoneyResponse]
52
53
  ]:
53
54
  """
54
55
  批量修改人的资金
@@ -80,7 +81,7 @@ class EconomyOrgService:
80
81
 
81
82
  def GetOrg(
82
83
  self, req: Union[org_service.GetOrgRequest, dict], dict_return: bool = True
83
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], org_service.GetOrgResponse]]:
84
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], org_service.GetOrgResponse]]:
84
85
  """
85
86
  批量查询组织的经济情况(员工、岗位、资金、货物)
86
87
  Query the economic status of the organization (employees, positions, funds, goods) in batches
@@ -100,7 +101,7 @@ class EconomyOrgService:
100
101
  self,
101
102
  req: Union[org_service.UpdateOrgMoneyRequest, dict],
102
103
  dict_return: bool = True,
103
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], org_service.UpdateOrgMoneyResponse]]:
104
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], org_service.UpdateOrgMoneyResponse]]:
104
105
  """
105
106
  批量修改组织的资金
106
107
  Modify organization’s money in batches
@@ -123,7 +124,7 @@ class EconomyOrgService:
123
124
  self,
124
125
  req: Union[org_service.UpdateOrgGoodsRequest, dict],
125
126
  dict_return: bool = True,
126
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], org_service.UpdateOrgGoodsResponse]]:
127
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], org_service.UpdateOrgGoodsResponse]]:
127
128
  """
128
129
  批量修改组织的货物
129
130
  Modify organization’s goods in batches
@@ -147,7 +148,7 @@ class EconomyOrgService:
147
148
  req: Union[org_service.UpdateOrgEmployeeRequest, dict],
148
149
  dict_return: bool = True,
149
150
  ) -> Coroutine[
150
- Any, Any, Union[Dict[str, Any], org_service.UpdateOrgEmployeeResponse]
151
+ Any, Any, Union[dict[str, Any], org_service.UpdateOrgEmployeeResponse]
151
152
  ]:
152
153
  """
153
154
  批量修改组织的员工
@@ -171,7 +172,7 @@ class EconomyOrgService:
171
172
  self,
172
173
  req: Union[org_service.UpdateOrgJobRequest, dict],
173
174
  dict_return: bool = True,
174
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], org_service.UpdateOrgJobResponse]]:
175
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], org_service.UpdateOrgJobResponse]]:
175
176
  """
176
177
  批量修改组织的岗位
177
178
  Modify organization’s jobs in batches
@@ -1,4 +1,5 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from typing import Any,cast, Union
2
+ from collections.abc import Awaitable, Coroutine
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
@@ -21,7 +22,7 @@ class LaneService:
21
22
 
22
23
  def GetLane(
23
24
  self, req: Union[lane_service.GetLaneRequest, dict], dict_return: bool = True
24
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], lane_service.GetLaneResponse]]:
25
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], lane_service.GetLaneResponse]]:
25
26
  """
26
27
  获取Lane的信息
27
28
  Get Lane's information
@@ -41,7 +42,7 @@ class LaneService:
41
42
  self,
42
43
  req: Union[lane_service.SetLaneMaxVRequest, dict],
43
44
  dict_return: bool = True,
44
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], lane_service.SetLaneMaxVResponse]]:
45
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], lane_service.SetLaneMaxVResponse]]:
45
46
  """
46
47
  设置Lane的最大速度(限速)
47
48
  Set the maximum speed of Lane (speed limit)
@@ -64,7 +65,7 @@ class LaneService:
64
65
  req: Union[lane_service.SetLaneRestrictionRequest, dict],
65
66
  dict_return: bool = True,
66
67
  ) -> Coroutine[
67
- Any, Any, Union[Dict[str, Any], lane_service.SetLaneRestrictionResponse]
68
+ Any, Any, Union[dict[str, Any], lane_service.SetLaneRestrictionResponse]
68
69
  ]:
69
70
  """
70
71
  设置Lane的限制
@@ -89,7 +90,7 @@ class LaneService:
89
90
  req: Union[lane_service.GetLaneByLongLatBBoxRequest, dict],
90
91
  dict_return: bool = True,
91
92
  ) -> Coroutine[
92
- Any, Any, Union[Dict[str, Any], lane_service.GetLaneByLongLatBBoxResponse]
93
+ Any, Any, Union[dict[str, Any], lane_service.GetLaneByLongLatBBoxResponse]
93
94
  ]:
94
95
  """
95
96
  获取特定区域内的Lane的信息
@@ -1,9 +1,11 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from collections.abc import Awaitable, Coroutine
2
+ from typing import Any, Union, cast
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
5
6
  from pycityproto.city.map.v2 import traffic_light_service_pb2 as light_service
6
- from pycityproto.city.map.v2 import traffic_light_service_pb2_grpc as light_grpc
7
+ from pycityproto.city.map.v2 import \
8
+ traffic_light_service_pb2_grpc as light_grpc
7
9
 
8
10
  from ..utils.protobuf import async_parse
9
11
 
@@ -21,10 +23,10 @@ class LightService:
21
23
 
22
24
  def GetTrafficLight(
23
25
  self,
24
- req: Union[light_service.GetTrafficLightRequest, Dict[str, Any]],
26
+ req: Union[light_service.GetTrafficLightRequest, dict[str, Any]],
25
27
  dict_return: bool = True,
26
28
  ) -> Coroutine[
27
- Any, Any, Union[Dict[str, Any], light_service.GetTrafficLightResponse]
29
+ Any, Any, Union[dict[str, Any], light_service.GetTrafficLightResponse]
28
30
  ]:
29
31
  """
30
32
  获取路口的红绿灯信息
@@ -46,10 +48,10 @@ class LightService:
46
48
 
47
49
  def SetTrafficLight(
48
50
  self,
49
- req: Union[light_service.SetTrafficLightRequest, Dict[str, Any]],
51
+ req: Union[light_service.SetTrafficLightRequest, dict[str, Any]],
50
52
  dict_return: bool = True,
51
53
  ) -> Coroutine[
52
- Any, Any, Union[Dict[str, Any], light_service.SetTrafficLightResponse]
54
+ Any, Any, Union[dict[str, Any], light_service.SetTrafficLightResponse]
53
55
  ]:
54
56
  """
55
57
  设置路口的红绿灯信息
@@ -74,7 +76,7 @@ class LightService:
74
76
  req: Union[light_service.SetTrafficLightPhaseRequest, dict],
75
77
  dict_return: bool = True,
76
78
  ) -> Coroutine[
77
- Any, Any, Union[Dict[str, Any], light_service.SetTrafficLightPhaseResponse]
79
+ Any, Any, Union[dict[str, Any], light_service.SetTrafficLightPhaseResponse]
78
80
  ]:
79
81
  """
80
82
  设置路口的红绿灯相位
@@ -99,7 +101,7 @@ class LightService:
99
101
  req: Union[light_service.SetTrafficLightStatusRequest, dict],
100
102
  dict_return: bool = True,
101
103
  ) -> Coroutine[
102
- Any, Any, Union[Dict[str, Any], light_service.SetTrafficLightStatusResponse]
104
+ Any, Any, Union[dict[str, Any], light_service.SetTrafficLightStatusResponse]
103
105
  ]:
104
106
  """
105
107
  设置路口的红绿灯状态
@@ -1,5 +1,6 @@
1
1
  import warnings
2
- from typing import Any, Awaitable, Coroutine, Dict, Union, cast
2
+ from collections.abc import Awaitable, Coroutine
3
+ from typing import Any, Union, cast
3
4
 
4
5
  import grpc
5
6
  from google.protobuf.json_format import ParseDict
@@ -51,7 +52,7 @@ class PersonService:
51
52
  self,
52
53
  req: Union[person_service.GetPersonRequest, dict],
53
54
  dict_return: bool = True,
54
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], person_service.GetPersonResponse]]:
55
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], person_service.GetPersonResponse]]:
55
56
  """
56
57
  获取person信息
57
58
  Get person information
@@ -73,7 +74,7 @@ class PersonService:
73
74
  self,
74
75
  req: Union[person_service.AddPersonRequest, dict],
75
76
  dict_return: bool = True,
76
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], person_service.AddPersonResponse]]:
77
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], person_service.AddPersonResponse]]:
77
78
  """
78
79
  新增person
79
80
  Add a new person
@@ -95,7 +96,7 @@ class PersonService:
95
96
  self,
96
97
  req: Union[person_service.SetScheduleRequest, dict],
97
98
  dict_return: bool = True,
98
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], person_service.SetScheduleResponse]]:
99
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], person_service.SetScheduleResponse]]:
99
100
  """
100
101
  修改person的schedule
101
102
  set person's schedule
@@ -118,7 +119,7 @@ class PersonService:
118
119
  self,
119
120
  req: Union[person_service.GetPersonsRequest, dict],
120
121
  dict_return: bool = True,
121
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], person_service.GetPersonsResponse]]:
122
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], person_service.GetPersonsResponse]]:
122
123
  """
123
124
  获取多个person信息
124
125
  Get information of multiple persons
@@ -142,7 +143,7 @@ class PersonService:
142
143
  req: Union[person_service.GetPersonByLongLatBBoxRequest, dict],
143
144
  dict_return: bool = True,
144
145
  ) -> Coroutine[
145
- Any, Any, Union[Dict[str, Any], person_service.GetPersonByLongLatBBoxResponse]
146
+ Any, Any, Union[dict[str, Any], person_service.GetPersonByLongLatBBoxResponse]
146
147
  ]:
147
148
  """
148
149
  获取特定区域内的person
@@ -167,7 +168,7 @@ class PersonService:
167
168
  req: Union[person_service.GetAllVehiclesRequest, dict],
168
169
  dict_return: bool = True,
169
170
  ) -> Coroutine[
170
- Any, Any, Union[Dict[str, Any], person_service.GetAllVehiclesResponse]
171
+ Any, Any, Union[dict[str, Any], person_service.GetAllVehiclesResponse]
171
172
  ]:
172
173
  """
173
174
  获取所有车辆
@@ -192,7 +193,7 @@ class PersonService:
192
193
  req: Union[person_service.ResetPersonPositionRequest, dict],
193
194
  dict_return: bool = True,
194
195
  ) -> Coroutine[
195
- Any, Any, Union[Dict[str, Any], person_service.ResetPersonPositionResponse]
196
+ Any, Any, Union[dict[str, Any], person_service.ResetPersonPositionResponse]
196
197
  ]:
197
198
  """
198
199
  重置人的位置(将停止当前正在进行的出行,转为sleep状态)
@@ -219,7 +220,7 @@ class PersonService:
219
220
  req: Union[person_service.SetControlledVehicleIDsRequest, dict],
220
221
  dict_return: bool = True,
221
222
  ) -> Coroutine[
222
- Any, Any, Union[Dict[str, Any], person_service.SetControlledVehicleIDsResponse]
223
+ Any, Any, Union[dict[str, Any], person_service.SetControlledVehicleIDsResponse]
223
224
  ]:
224
225
  """
225
226
  设置由外部控制行为的vehicle
@@ -246,7 +247,7 @@ class PersonService:
246
247
  ) -> Coroutine[
247
248
  Any,
248
249
  Any,
249
- Union[Dict[str, Any], person_service.FetchControlledVehicleEnvsResponse],
250
+ Union[dict[str, Any], person_service.FetchControlledVehicleEnvsResponse],
250
251
  ]:
251
252
  """
252
253
  获取由外部控制行为的vehicle的环境信息
@@ -273,7 +274,7 @@ class PersonService:
273
274
  ) -> Coroutine[
274
275
  Any,
275
276
  Any,
276
- Union[Dict[str, Any], person_service.SetControlledVehicleActionsResponse],
277
+ Union[dict[str, Any], person_service.SetControlledVehicleActionsResponse],
277
278
  ]:
278
279
  """
279
280
  设置由外部控制行为的vehicle的行为
@@ -1,4 +1,5 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from collections.abc import Awaitable, Coroutine
2
+ from typing import Any, Union, cast
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
@@ -21,7 +22,7 @@ class RoadService:
21
22
 
22
23
  def GetRoad(
23
24
  self, req: Union[road_service.GetRoadRequest, dict], dict_return: bool = True
24
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], road_service.GetRoadResponse]]:
25
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], road_service.GetRoadResponse]]:
25
26
  """
26
27
  查询道路信息
27
28
  Query road information
@@ -1,4 +1,5 @@
1
- from typing import Any, Awaitable, Coroutine, cast, Union, Dict
1
+ from collections.abc import Awaitable, Coroutine
2
+ from typing import Any, Union, cast
2
3
 
3
4
  import grpc
4
5
  from google.protobuf.json_format import ParseDict
@@ -21,7 +22,7 @@ class SocialService:
21
22
 
22
23
  def Send(
23
24
  self, req: Union[social_service.SendRequest, dict], dict_return: bool = True
24
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], social_service.SendResponse]]:
25
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], social_service.SendResponse]]:
25
26
  """
26
27
  发送消息
27
28
  Send message
@@ -39,7 +40,7 @@ class SocialService:
39
40
 
40
41
  def Receive(
41
42
  self, req: Union[social_service.ReceiveRequest, dict], dict_return: bool = True
42
- ) -> Coroutine[Any, Any, Union[Dict[str, Any], social_service.ReceiveResponse]]:
43
+ ) -> Coroutine[Any, Any, Union[dict[str, Any], social_service.ReceiveResponse]]:
43
44
  """
44
45
  接收消息
45
46
  Receive message
@@ -1,13 +1,15 @@
1
- from typing import Any, Awaitable, TypeVar, Union, Dict
2
- from google.protobuf.message import Message
1
+ from collections.abc import Awaitable
2
+ from typing import Any, TypeVar, Union
3
+
3
4
  from google.protobuf.json_format import MessageToDict
5
+ from google.protobuf.message import Message
4
6
 
5
7
  __all__ = ["parse", "async_parse"]
6
8
 
7
9
  T = TypeVar("T", bound=Message)
8
10
 
9
11
 
10
- def parse(res: T, dict_return: bool) -> Union[Dict[str, Any], T]:
12
+ def parse(res: T, dict_return: bool) -> Union[dict[str, Any], T]:
11
13
  """
12
14
  将Protobuf返回值转换为dict或者原始值
13
15
  Convert Protobuf return value to dict or original value
@@ -23,7 +25,7 @@ def parse(res: T, dict_return: bool) -> Union[Dict[str, Any], T]:
23
25
  return res
24
26
 
25
27
 
26
- async def async_parse(res: Awaitable[T], dict_return: bool) -> Union[Dict[str, Any], T]:
28
+ async def async_parse(res: Awaitable[T], dict_return: bool) -> Union[dict[str, Any], T]:
27
29
  """
28
30
  将Protobuf await返回值转换为dict或者原始值
29
31
  Convert Protobuf await return value to dict or original value
@@ -0,0 +1,11 @@
1
+ """LLM相关模块"""
2
+
3
+ from .embeddings import SentenceEmbedding, SimpleEmbedding
4
+ from .llm import LLM, LLMConfig
5
+
6
+ __all__ = [
7
+ "LLM",
8
+ "LLMConfig",
9
+ "SentenceEmbedding",
10
+ "SimpleEmbedding",
11
+ ]