pycityagent 2.0.0a20__py3-none-any.whl → 2.0.0a22__py3-none-any.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/agent.py +169 -63
- pycityagent/environment/sim/aoi_service.py +2 -1
- pycityagent/environment/sim/clock_service.py +2 -1
- pycityagent/environment/sim/economy_services.py +9 -8
- pycityagent/environment/sim/lane_service.py +6 -5
- pycityagent/environment/sim/light_service.py +10 -8
- pycityagent/environment/sim/person_service.py +12 -11
- pycityagent/environment/sim/road_service.py +3 -2
- pycityagent/environment/sim/social_service.py +4 -3
- pycityagent/environment/utils/protobuf.py +6 -4
- pycityagent/memory/memory_base.py +7 -6
- pycityagent/memory/profile.py +7 -6
- pycityagent/memory/self_define.py +8 -7
- pycityagent/memory/state.py +7 -6
- pycityagent/memory/utils.py +2 -1
- pycityagent/simulation/__init__.py +2 -1
- pycityagent/simulation/agentgroup.py +129 -3
- pycityagent/simulation/simulation.py +52 -27
- pycityagent/simulation/storage/pg.py +139 -0
- pycityagent/utils/parsers/json_parser.py +3 -3
- pycityagent/utils/pg_query.py +80 -0
- pycityagent/workflow/block.py +2 -1
- pycityagent/workflow/tool.py +32 -24
- {pycityagent-2.0.0a20.dist-info → pycityagent-2.0.0a22.dist-info}/METADATA +1 -1
- {pycityagent-2.0.0a20.dist-info → pycityagent-2.0.0a22.dist-info}/RECORD +26 -24
- {pycityagent-2.0.0a20.dist-info → pycityagent-2.0.0a22.dist-info}/WHEEL +0 -0
pycityagent/agent.py
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
"""智能体模板类及其定义"""
|
2
2
|
|
3
3
|
import asyncio
|
4
|
+
import json
|
4
5
|
import logging
|
5
6
|
import random
|
6
7
|
import uuid
|
7
8
|
from abc import ABC, abstractmethod
|
8
9
|
from copy import deepcopy
|
9
|
-
from datetime import datetime
|
10
|
+
from datetime import datetime, timezone
|
10
11
|
from enum import Enum
|
11
12
|
from typing import Any, Optional
|
12
13
|
from uuid import UUID
|
13
14
|
|
14
15
|
import fastavro
|
16
|
+
import ray
|
15
17
|
from mosstool.util.format_converter import dict2pb
|
16
18
|
from pycityproto.city.person.v2 import person_pb2 as person_pb2
|
17
19
|
|
@@ -56,6 +58,7 @@ class Agent(ABC):
|
|
56
58
|
mlflow_client: Optional[MlflowClient] = None,
|
57
59
|
memory: Optional[Memory] = None,
|
58
60
|
avro_file: Optional[dict[str, str]] = None,
|
61
|
+
copy_writer: Optional[ray.ObjectRef] = None,
|
59
62
|
) -> None:
|
60
63
|
"""
|
61
64
|
Initialize the Agent.
|
@@ -70,6 +73,7 @@ class Agent(ABC):
|
|
70
73
|
mlflow_client (MlflowClient, optional): The Mlflow object. Defaults to None.
|
71
74
|
memory (Memory, optional): The memory of the agent. Defaults to None.
|
72
75
|
avro_file (dict[str, str], optional): The avro file of the agent. Defaults to None.
|
76
|
+
copy_writer (ray.ObjectRef): The copy_writer of the agent. Defaults to None.
|
73
77
|
"""
|
74
78
|
self._name = name
|
75
79
|
self._type = type
|
@@ -88,6 +92,8 @@ class Agent(ABC):
|
|
88
92
|
self._interview_history: list[dict] = [] # 存储采访历史
|
89
93
|
self._person_template = PersonService.default_dict_person()
|
90
94
|
self._avro_file = avro_file
|
95
|
+
self._pgsql_writer = copy_writer
|
96
|
+
self._last_asyncio_pg_task = None # 将SQL写入的IO隐藏到计算任务后
|
91
97
|
|
92
98
|
def __getstate__(self):
|
93
99
|
state = self.__dict__.copy()
|
@@ -143,6 +149,12 @@ class Agent(ABC):
|
|
143
149
|
"""
|
144
150
|
self._avro_file = avro_file
|
145
151
|
|
152
|
+
def set_pgsql_writer(self, pgsql_writer: ray.ObjectRef):
|
153
|
+
"""
|
154
|
+
Set the PostgreSQL copy writer of the agent.
|
155
|
+
"""
|
156
|
+
self._pgsql_writer = pgsql_writer
|
157
|
+
|
146
158
|
@property
|
147
159
|
def uuid(self):
|
148
160
|
"""The Agent's UUID"""
|
@@ -198,6 +210,15 @@ class Agent(ABC):
|
|
198
210
|
)
|
199
211
|
return self._simulator
|
200
212
|
|
213
|
+
@property
|
214
|
+
def copy_writer(self):
|
215
|
+
"""Pg Copy Writer"""
|
216
|
+
if self._pgsql_writer is None:
|
217
|
+
raise RuntimeError(
|
218
|
+
f"Copy Writer access before assignment, please `set_pgsql_writer` first!"
|
219
|
+
)
|
220
|
+
return self._pgsql_writer
|
221
|
+
|
201
222
|
async def generate_user_survey_response(self, survey: dict) -> str:
|
202
223
|
"""生成回答 —— 可重写
|
203
224
|
基于智能体的记忆和当前状态,生成对问卷调查的回答。
|
@@ -237,8 +258,8 @@ class Agent(ABC):
|
|
237
258
|
|
238
259
|
async def _process_survey(self, survey: dict):
|
239
260
|
survey_response = await self.generate_user_survey_response(survey)
|
240
|
-
|
241
|
-
|
261
|
+
_date_time = datetime.now(timezone.utc)
|
262
|
+
# Avro
|
242
263
|
response_to_avro = [
|
243
264
|
{
|
244
265
|
"id": self._uuid,
|
@@ -246,11 +267,41 @@ class Agent(ABC):
|
|
246
267
|
"t": await self.simulator.get_simulator_second_from_start_of_day(),
|
247
268
|
"survey_id": survey["id"],
|
248
269
|
"result": survey_response,
|
249
|
-
"created_at": int(
|
270
|
+
"created_at": int(_date_time.timestamp() * 1000),
|
250
271
|
}
|
251
272
|
]
|
252
|
-
|
253
|
-
|
273
|
+
if self._avro_file is not None:
|
274
|
+
with open(self._avro_file["survey"], "a+b") as f:
|
275
|
+
fastavro.writer(f, SURVEY_SCHEMA, response_to_avro, codec="snappy")
|
276
|
+
# Pg
|
277
|
+
if self._pgsql_writer is not None:
|
278
|
+
if self._last_asyncio_pg_task is not None:
|
279
|
+
await self._last_asyncio_pg_task
|
280
|
+
_keys = [
|
281
|
+
"id",
|
282
|
+
"day",
|
283
|
+
"t",
|
284
|
+
"survey_id",
|
285
|
+
"result",
|
286
|
+
]
|
287
|
+
_data_tuples: list[tuple] = []
|
288
|
+
# str to json
|
289
|
+
for _dict in response_to_avro:
|
290
|
+
res = _dict["result"]
|
291
|
+
_dict["result"] = json.dumps(
|
292
|
+
{
|
293
|
+
"result": res,
|
294
|
+
}
|
295
|
+
)
|
296
|
+
_data_list = [_dict[k] for k in _keys]
|
297
|
+
# created_at
|
298
|
+
_data_list.append(_date_time)
|
299
|
+
_data_tuples.append(tuple(_data_list))
|
300
|
+
self._last_asyncio_pg_task = (
|
301
|
+
self._pgsql_writer.async_write_survey.remote( # type:ignore
|
302
|
+
_data_tuples
|
303
|
+
)
|
304
|
+
)
|
254
305
|
|
255
306
|
async def generate_user_chat_response(self, question: str) -> str:
|
256
307
|
"""生成回答 —— 可重写
|
@@ -290,34 +341,52 @@ class Agent(ABC):
|
|
290
341
|
return response # type:ignore
|
291
342
|
|
292
343
|
async def _process_interview(self, payload: dict):
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
344
|
+
pg_list: list[tuple[dict, datetime]] = []
|
345
|
+
auros: list[dict] = []
|
346
|
+
_date_time = datetime.now(timezone.utc)
|
347
|
+
_interview_dict = {
|
348
|
+
"id": self._uuid,
|
349
|
+
"day": await self.simulator.get_simulator_day(),
|
350
|
+
"t": await self.simulator.get_simulator_second_from_start_of_day(),
|
351
|
+
"type": 2,
|
352
|
+
"speaker": "user",
|
353
|
+
"content": payload["content"],
|
354
|
+
"created_at": int(_date_time.timestamp() * 1000),
|
355
|
+
}
|
356
|
+
auros.append(_interview_dict)
|
357
|
+
pg_list.append((_interview_dict, _date_time))
|
304
358
|
question = payload["content"]
|
305
359
|
response = await self.generate_user_chat_response(question)
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
)
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
360
|
+
_date_time = datetime.now(timezone.utc)
|
361
|
+
_interview_dict = {
|
362
|
+
"id": self._uuid,
|
363
|
+
"day": await self.simulator.get_simulator_day(),
|
364
|
+
"t": await self.simulator.get_simulator_second_from_start_of_day(),
|
365
|
+
"type": 2,
|
366
|
+
"speaker": "",
|
367
|
+
"content": response,
|
368
|
+
"created_at": int(_date_time.timestamp() * 1000),
|
369
|
+
}
|
370
|
+
auros.append(_interview_dict)
|
371
|
+
pg_list.append((_interview_dict, _date_time))
|
372
|
+
# Avro
|
373
|
+
if self._avro_file is not None:
|
374
|
+
with open(self._avro_file["dialog"], "a+b") as f:
|
375
|
+
fastavro.writer(f, DIALOG_SCHEMA, auros, codec="snappy")
|
376
|
+
# Pg
|
377
|
+
if self._pgsql_writer is not None:
|
378
|
+
if self._last_asyncio_pg_task is not None:
|
379
|
+
await self._last_asyncio_pg_task
|
380
|
+
_keys = ["id", "day", "t", "type", "speaker", "content", "created_at"]
|
381
|
+
_data = [
|
382
|
+
tuple([_dict[k] if k != "created_at" else _date_time for k in _keys])
|
383
|
+
for _dict, _date_time in pg_list
|
384
|
+
]
|
385
|
+
self._last_asyncio_pg_task = (
|
386
|
+
self._pgsql_writer.async_write_dialog.remote( # type:ignore
|
387
|
+
_data
|
388
|
+
)
|
389
|
+
)
|
321
390
|
|
322
391
|
async def process_agent_chat_response(self, payload: dict) -> str:
|
323
392
|
resp = f"Agent {self._uuid} received agent chat response: {payload}"
|
@@ -325,22 +394,39 @@ class Agent(ABC):
|
|
325
394
|
return resp
|
326
395
|
|
327
396
|
async def _process_agent_chat(self, payload: dict):
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
397
|
+
pg_list: list[tuple[dict, datetime]] = []
|
398
|
+
auros: list[dict] = []
|
399
|
+
_date_time = datetime.now(timezone.utc)
|
400
|
+
_chat_dict = {
|
401
|
+
"id": self._uuid,
|
402
|
+
"day": payload["day"],
|
403
|
+
"t": payload["t"],
|
404
|
+
"type": 1,
|
405
|
+
"speaker": payload["from"],
|
406
|
+
"content": payload["content"],
|
407
|
+
"created_at": int(_date_time.timestamp() * 1000),
|
408
|
+
}
|
409
|
+
auros.append(_chat_dict)
|
410
|
+
pg_list.append((_chat_dict, _date_time))
|
339
411
|
asyncio.create_task(self.process_agent_chat_response(payload))
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
412
|
+
# Avro
|
413
|
+
if self._avro_file is not None:
|
414
|
+
with open(self._avro_file["dialog"], "a+b") as f:
|
415
|
+
fastavro.writer(f, DIALOG_SCHEMA, auros, codec="snappy")
|
416
|
+
# Pg
|
417
|
+
if self._pgsql_writer is not None:
|
418
|
+
if self._last_asyncio_pg_task is not None:
|
419
|
+
await self._last_asyncio_pg_task
|
420
|
+
_keys = ["id", "day", "t", "type", "speaker", "content", "created_at"]
|
421
|
+
_data = [
|
422
|
+
tuple([_dict[k] if k != "created_at" else _date_time for k in _keys])
|
423
|
+
for _dict, _date_time in pg_list
|
424
|
+
]
|
425
|
+
self._last_asyncio_pg_task = (
|
426
|
+
self._pgsql_writer.async_write_dialog.remote( # type:ignore
|
427
|
+
_data
|
428
|
+
)
|
429
|
+
)
|
344
430
|
|
345
431
|
# Callback functions for MQTT message
|
346
432
|
async def handle_agent_chat_message(self, payload: dict):
|
@@ -372,33 +458,53 @@ class Agent(ABC):
|
|
372
458
|
topic = f"exps/{self._exp_id}/agents/{to_agent_uuid}/{sub_topic}"
|
373
459
|
await self._messager.send_message(topic, payload)
|
374
460
|
|
375
|
-
async def send_message_to_agent(self, to_agent_uuid: str, content: str):
|
461
|
+
async def send_message_to_agent(self, to_agent_uuid: str, content: str, type: str = "social"):
|
376
462
|
"""通过 Messager 发送消息"""
|
377
463
|
if self._messager is None:
|
378
464
|
raise RuntimeError("Messager is not set")
|
465
|
+
if type not in ["social", "economy"]:
|
466
|
+
logger.warning(f"Invalid message type: {type}, sent from {self._uuid}")
|
379
467
|
payload = {
|
380
468
|
"from": self._uuid,
|
381
469
|
"content": content,
|
470
|
+
"type": type,
|
382
471
|
"timestamp": int(datetime.now().timestamp() * 1000),
|
383
472
|
"day": await self.simulator.get_simulator_day(),
|
384
473
|
"t": await self.simulator.get_simulator_second_from_start_of_day(),
|
385
474
|
}
|
386
475
|
await self._send_message(to_agent_uuid, payload, "agent-chat")
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
476
|
+
pg_list: list[tuple[dict, datetime]] = []
|
477
|
+
auros: list[dict] = []
|
478
|
+
_date_time = datetime.now(timezone.utc)
|
479
|
+
_message_dict = {
|
480
|
+
"id": self._uuid,
|
481
|
+
"day": await self.simulator.get_simulator_day(),
|
482
|
+
"t": await self.simulator.get_simulator_second_from_start_of_day(),
|
483
|
+
"type": 1,
|
484
|
+
"speaker": self._uuid,
|
485
|
+
"content": content,
|
486
|
+
"created_at": int(datetime.now().timestamp() * 1000),
|
487
|
+
}
|
488
|
+
auros.append(_message_dict)
|
489
|
+
pg_list.append((_message_dict, _date_time))
|
490
|
+
# Avro
|
491
|
+
if self._avro_file is not None and type == "social":
|
492
|
+
with open(self._avro_file["dialog"], "a+b") as f:
|
493
|
+
fastavro.writer(f, DIALOG_SCHEMA, auros, codec="snappy")
|
494
|
+
# Pg
|
495
|
+
if self._pgsql_writer is not None and type == "social":
|
496
|
+
if self._last_asyncio_pg_task is not None:
|
497
|
+
await self._last_asyncio_pg_task
|
498
|
+
_keys = ["id", "day", "t", "type", "speaker", "content", "created_at"]
|
499
|
+
_data = [
|
500
|
+
tuple([_dict[k] if k != "created_at" else _date_time for k in _keys])
|
501
|
+
for _dict, _date_time in pg_list
|
502
|
+
]
|
503
|
+
self._last_asyncio_pg_task = (
|
504
|
+
self._pgsql_writer.async_write_dialog.remote( # type:ignore
|
505
|
+
_data
|
506
|
+
)
|
507
|
+
)
|
402
508
|
|
403
509
|
# Agent logic
|
404
510
|
@abstractmethod
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from typing import Any,
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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,
|
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[
|
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[
|
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[
|
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[
|
93
|
+
Any, Any, Union[dict[str, Any], lane_service.GetLaneByLongLatBBoxResponse]
|
93
94
|
]:
|
94
95
|
"""
|
95
96
|
获取特定区域内的Lane的信息
|
@@ -1,9 +1,11 @@
|
|
1
|
-
from
|
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
|
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,
|
26
|
+
req: Union[light_service.GetTrafficLightRequest, dict[str, Any]],
|
25
27
|
dict_return: bool = True,
|
26
28
|
) -> Coroutine[
|
27
|
-
Any, Any, Union[
|
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,
|
51
|
+
req: Union[light_service.SetTrafficLightRequest, dict[str, Any]],
|
50
52
|
dict_return: bool = True,
|
51
53
|
) -> Coroutine[
|
52
|
-
Any, Any, Union[
|
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[
|
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[
|
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
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
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[
|
277
|
+
Union[dict[str, Any], person_service.SetControlledVehicleActionsResponse],
|
277
278
|
]:
|
278
279
|
"""
|
279
280
|
设置由外部控制行为的vehicle的行为
|
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
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[
|
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
|
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[
|
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[
|
43
|
+
) -> Coroutine[Any, Any, Union[dict[str, Any], social_service.ReceiveResponse]]:
|
43
44
|
"""
|
44
45
|
接收消息
|
45
46
|
Receive message
|