pycityagent 1.0.0__py3-none-any.whl → 2.0.0a1__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/__init__.py +7 -3
- pycityagent/agent.py +180 -284
- pycityagent/economy/__init__.py +5 -0
- pycityagent/economy/econ_client.py +307 -0
- pycityagent/environment/__init__.py +7 -0
- pycityagent/environment/interact/interact.py +141 -0
- pycityagent/environment/sence/__init__.py +0 -0
- pycityagent/{brain → environment/sence}/static.py +1 -1
- pycityagent/environment/sidecar/__init__.py +8 -0
- pycityagent/environment/sidecar/sidecarv2.py +109 -0
- pycityagent/environment/sim/__init__.py +27 -0
- pycityagent/environment/sim/aoi_service.py +38 -0
- pycityagent/environment/sim/client.py +126 -0
- pycityagent/environment/sim/clock_service.py +43 -0
- pycityagent/environment/sim/economy_services.py +191 -0
- pycityagent/environment/sim/lane_service.py +110 -0
- pycityagent/environment/sim/light_service.py +120 -0
- pycityagent/environment/sim/person_service.py +294 -0
- pycityagent/environment/sim/road_service.py +38 -0
- pycityagent/environment/sim/social_service.py +58 -0
- pycityagent/environment/simulator.py +369 -0
- pycityagent/environment/utils/__init__.py +8 -0
- pycityagent/environment/utils/geojson.py +26 -0
- pycityagent/environment/utils/grpc.py +57 -0
- pycityagent/environment/utils/map_utils.py +157 -0
- pycityagent/environment/utils/protobuf.py +39 -0
- pycityagent/llm/__init__.py +6 -0
- pycityagent/llm/embedding.py +136 -0
- pycityagent/llm/llm.py +430 -0
- pycityagent/llm/llmconfig.py +15 -0
- pycityagent/llm/utils.py +6 -0
- pycityagent/memory/__init__.py +11 -0
- pycityagent/memory/const.py +41 -0
- pycityagent/memory/memory.py +453 -0
- pycityagent/memory/memory_base.py +168 -0
- pycityagent/memory/profile.py +165 -0
- pycityagent/memory/self_define.py +165 -0
- pycityagent/memory/state.py +173 -0
- pycityagent/memory/utils.py +27 -0
- pycityagent/message/__init__.py +0 -0
- pycityagent/simulation/__init__.py +7 -0
- pycityagent/simulation/interview.py +36 -0
- pycityagent/simulation/simulation.py +286 -0
- pycityagent/simulation/survey/__init__.py +9 -0
- pycityagent/simulation/survey/manager.py +67 -0
- pycityagent/simulation/survey/models.py +49 -0
- pycityagent/simulation/ui/__init__.py +3 -0
- pycityagent/simulation/ui/interface.py +602 -0
- pycityagent/utils/__init__.py +0 -0
- pycityagent/utils/decorators.py +89 -0
- pycityagent/utils/parsers/__init__.py +12 -0
- pycityagent/utils/parsers/code_block_parser.py +37 -0
- pycityagent/utils/parsers/json_parser.py +86 -0
- pycityagent/utils/parsers/parser_base.py +60 -0
- pycityagent/workflow/__init__.py +22 -0
- pycityagent/workflow/block.py +137 -0
- pycityagent/workflow/prompt.py +72 -0
- pycityagent/workflow/tool.py +246 -0
- pycityagent/workflow/trigger.py +66 -0
- pycityagent-2.0.0a1.dist-info/METADATA +208 -0
- pycityagent-2.0.0a1.dist-info/RECORD +65 -0
- {pycityagent-1.0.0.dist-info → pycityagent-2.0.0a1.dist-info}/WHEEL +1 -2
- pycityagent/ac/__init__.py +0 -6
- pycityagent/ac/ac.py +0 -50
- pycityagent/ac/action.py +0 -14
- pycityagent/ac/controled.py +0 -13
- pycityagent/ac/converse.py +0 -31
- pycityagent/ac/idle.py +0 -17
- pycityagent/ac/shop.py +0 -80
- pycityagent/ac/trip.py +0 -37
- pycityagent/brain/__init__.py +0 -10
- pycityagent/brain/brain.py +0 -52
- pycityagent/brain/brainfc.py +0 -10
- pycityagent/brain/memory.py +0 -541
- pycityagent/brain/persistence/social.py +0 -1
- pycityagent/brain/persistence/spatial.py +0 -14
- pycityagent/brain/reason/shop.py +0 -37
- pycityagent/brain/reason/social.py +0 -148
- pycityagent/brain/reason/trip.py +0 -67
- pycityagent/brain/reason/user.py +0 -122
- pycityagent/brain/retrive/social.py +0 -6
- pycityagent/brain/scheduler.py +0 -408
- pycityagent/brain/sence.py +0 -375
- pycityagent/cc/__init__.py +0 -5
- pycityagent/cc/cc.py +0 -102
- pycityagent/cc/conve.py +0 -6
- pycityagent/cc/idle.py +0 -20
- pycityagent/cc/shop.py +0 -6
- pycityagent/cc/trip.py +0 -13
- pycityagent/cc/user.py +0 -13
- pycityagent/hubconnector/__init__.py +0 -3
- pycityagent/hubconnector/hubconnector.py +0 -137
- pycityagent/image/__init__.py +0 -3
- pycityagent/image/image.py +0 -158
- pycityagent/simulator.py +0 -161
- pycityagent/st/__init__.py +0 -4
- pycityagent/st/st.py +0 -96
- pycityagent/urbanllm/__init__.py +0 -3
- pycityagent/urbanllm/urbanllm.py +0 -132
- pycityagent-1.0.0.dist-info/LICENSE +0 -21
- pycityagent-1.0.0.dist-info/METADATA +0 -181
- pycityagent-1.0.0.dist-info/RECORD +0 -48
- pycityagent-1.0.0.dist-info/top_level.txt +0 -1
- /pycityagent/{brain/persistence/__init__.py → config.py} +0 -0
- /pycityagent/{brain/reason → environment/interact}/__init__.py +0 -0
- /pycityagent/{brain/retrive → environment/message}/__init__.py +0 -0
pycityagent/__init__.py
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
"""
|
2
|
+
Pycityagent: 城市智能体构建框架
|
3
|
+
"""
|
3
4
|
|
4
|
-
|
5
|
+
from .agent import Agent, CitizenAgent, InstitutionAgent
|
6
|
+
from .environment import Simulator
|
7
|
+
|
8
|
+
__all__ = ["Agent", "Simulator", "CitizenAgent", "InstitutionAgent"]
|
pycityagent/agent.py
CHANGED
@@ -1,318 +1,214 @@
|
|
1
|
+
"""智能体模板类及其定义"""
|
2
|
+
|
1
3
|
from abc import ABC, abstractmethod
|
2
|
-
from
|
3
|
-
|
4
|
-
from
|
5
|
-
import asyncio
|
6
|
-
import time
|
7
|
-
from pycitysim.sim import CityClient
|
8
|
-
|
9
|
-
from pycityagent.urbanllm import UrbanLLM
|
10
|
-
from .urbanllm import UrbanLLM
|
11
|
-
from .brain.brain import Brain
|
12
|
-
from .hubconnector.hubconnector import HubConnector
|
13
|
-
from .image.image import AgentImage
|
14
|
-
from .ac.ac import ActionController
|
15
|
-
from .cc.cc import CommondController
|
16
|
-
from .st.st import StateTransformer
|
17
|
-
|
18
|
-
|
19
|
-
class Template:
|
20
|
-
"""
|
21
|
-
The basic template of Agent
|
22
|
-
"""
|
23
|
-
def __init__(self, name, server, soul:UrbanLLM=None, simulator=None, id:int=None) -> None:
|
24
|
-
self.agent_name = name
|
25
|
-
self._client = CityClient(server)
|
26
|
-
self._soul = soul
|
27
|
-
self._simulator = simulator
|
28
|
-
self._id = id
|
4
|
+
from datetime import datetime
|
5
|
+
from enum import Enum
|
6
|
+
from typing import Dict, List, Optional
|
29
7
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
8
|
+
from .economy import EconomyClient
|
9
|
+
from .environment import Simulator
|
10
|
+
from .llm import LLM
|
11
|
+
from .memory import Memory
|
34
12
|
|
35
|
-
Args:
|
36
|
-
- llm_engine (UrbanLLM): the soul
|
37
|
-
"""
|
38
|
-
self._soul = llm_engine
|
39
13
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Add related simulator
|
14
|
+
class AgentType(Enum):
|
15
|
+
"""
|
16
|
+
Agent类型
|
44
17
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
self._simulator = simulator
|
18
|
+
- Citizen, Citizen type agent
|
19
|
+
- Institution, Orgnization or institution type agent
|
20
|
+
"""
|
49
21
|
|
50
|
-
|
51
|
-
|
52
|
-
|
22
|
+
Unspecified = "Unspecified"
|
23
|
+
Citizen = "Citizen"
|
24
|
+
Institution = "Institution"
|
53
25
|
|
54
|
-
|
26
|
+
|
27
|
+
class Agent(ABC):
|
55
28
|
"""
|
56
|
-
Agent
|
29
|
+
Agent base class
|
57
30
|
"""
|
31
|
+
|
58
32
|
def __init__(
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
scratch_file:str=None,
|
68
|
-
selfie:bool = False,
|
69
|
-
connect_to_hub:bool=False,
|
70
|
-
hub_url:str=None,
|
71
|
-
app_id:int=None,
|
72
|
-
app_secret:str=None,
|
73
|
-
profile_img:str=None
|
74
|
-
) -> None:
|
75
|
-
super().__init__(name, server, soul, simulator, id)
|
76
|
-
self.base = base
|
77
|
-
"""
|
78
|
-
Agent/Person的基本属性, Agent指被代理的Person, Person指模拟器中的背景人
|
79
|
-
The base attributes of Agent/Person. Agent is the Person being represented. Persons are background persons in simulator
|
80
|
-
- https://cityproto.sim.fiblab.net/#city.agent.v2.Agent
|
81
|
-
"""
|
82
|
-
self.motion = motion
|
83
|
-
"""
|
84
|
-
Agent/Person的运动信息
|
85
|
-
The motion information of Agent/Person
|
86
|
-
- https://cityproto.sim.fiblab.net/#city.agent.v2.AgentMotion
|
87
|
-
"""
|
88
|
-
if connect_to_hub:
|
89
|
-
self._hub_connector = HubConnector(
|
90
|
-
hub_url=hub_url,
|
91
|
-
app_id=app_id,
|
92
|
-
app_secret=app_secret,
|
93
|
-
agent=self,
|
94
|
-
profile_img=profile_img
|
95
|
-
)
|
96
|
-
else:
|
97
|
-
self._hub_connector = None
|
98
|
-
self._image = AgentImage(self, scratch_file, selfie)
|
99
|
-
"""
|
100
|
-
Agent画像
|
101
|
-
The Agent's Image
|
33
|
+
self,
|
34
|
+
name: str,
|
35
|
+
type: AgentType = AgentType.Unspecified,
|
36
|
+
llm_client: Optional[LLM] = None,
|
37
|
+
economy_client: Optional[EconomyClient] = None,
|
38
|
+
simulator: Optional[Simulator] = None,
|
39
|
+
memory: Optional[Memory] = None,
|
40
|
+
) -> None:
|
102
41
|
"""
|
103
|
-
|
104
|
-
"""
|
105
|
-
Agent的大脑
|
106
|
-
The Agent's Brain
|
107
|
-
"""
|
108
|
-
self._ac = ActionController(self)
|
109
|
-
"""
|
110
|
-
Agent的行为控制器
|
111
|
-
The Agent's ActionController
|
112
|
-
"""
|
113
|
-
self._cc = CommondController(self)
|
114
|
-
"""
|
115
|
-
Agent的命令控制器
|
116
|
-
The Agent's CommondController
|
117
|
-
"""
|
118
|
-
self._st = StateTransformer()
|
119
|
-
"""
|
120
|
-
与Agent关联的状态转移器
|
121
|
-
The related StateTransformer
|
122
|
-
"""
|
123
|
-
# * 默认trip构建
|
124
|
-
self.Scheduler.schedule_init()
|
125
|
-
|
126
|
-
def ConnectToHub(self, config:dict):
|
127
|
-
"""
|
128
|
-
与AppHub构建连接
|
129
|
-
Connect to AppHub
|
42
|
+
Initialize the Agent.
|
130
43
|
|
131
44
|
Args:
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
开启街景相关功能
|
148
|
-
Enable Streetview function
|
149
|
-
"""
|
150
|
-
self._brain.Sence.enable_streeview = True
|
45
|
+
name (str): The name of the agent.
|
46
|
+
type (AgentType): The type of the agent. Defaults to `AgentType.Unspecified`
|
47
|
+
llm_client (LLM): The language model client. Defaults to None.
|
48
|
+
economy_client (EconomyClient): The `EconomySim` client. Defaults to None.
|
49
|
+
simulator (Simulator, optional): The simulator object. Defaults to None.
|
50
|
+
memory (Memory, optional): The memory of the agent. Defaults to None.
|
51
|
+
"""
|
52
|
+
self._name = name
|
53
|
+
self._type = type
|
54
|
+
self._llm_client = llm_client
|
55
|
+
self._economy_client = economy_client
|
56
|
+
self._simulator = simulator
|
57
|
+
self._memory = memory
|
58
|
+
self._has_bound_to_simulator = False
|
59
|
+
self._interview_history: List[Dict] = [] # 存储采访历史
|
151
60
|
|
152
|
-
def
|
61
|
+
def set_memory(self, memory: Memory):
|
153
62
|
"""
|
154
|
-
|
155
|
-
Disable Streetview function
|
63
|
+
Set the memory of the agent.
|
156
64
|
"""
|
157
|
-
self.
|
65
|
+
self._memory = memory
|
158
66
|
|
159
|
-
def
|
67
|
+
def set_simulator(self, simulator: Simulator):
|
160
68
|
"""
|
161
|
-
|
162
|
-
Enable User Interaction function. The User Interaction function is the ability to interact with the related agent in OpenCity website console.
|
69
|
+
Set the simulator of the agent.
|
163
70
|
"""
|
164
|
-
self.
|
71
|
+
self._simulator = simulator
|
165
72
|
|
166
|
-
def
|
73
|
+
def set_economy_client(self, economy_client: EconomyClient):
|
167
74
|
"""
|
168
|
-
|
169
|
-
Disable User Interaction function
|
75
|
+
Set the economy_client of the agent.
|
170
76
|
"""
|
171
|
-
self.
|
77
|
+
self._economy_client = economy_client
|
172
78
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
79
|
+
@property
|
80
|
+
def LLM(self):
|
81
|
+
"""The Agent's LLM"""
|
82
|
+
if self._llm_client is None:
|
83
|
+
raise RuntimeError(
|
84
|
+
f"LLM access before assignment, please `set_llm_client` first!"
|
85
|
+
)
|
86
|
+
return self._llm_client
|
179
87
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
88
|
+
@property
|
89
|
+
def economy_client(self):
|
90
|
+
"""The Agent's EconomyClient"""
|
91
|
+
if self._economy_client is None:
|
92
|
+
raise RuntimeError(
|
93
|
+
f"EconomyClient access before assignment, please `set_economy_client` first!"
|
94
|
+
)
|
95
|
+
return self._economy_client
|
186
96
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
97
|
+
@property
|
98
|
+
def memory(self):
|
99
|
+
"""The Agent's Memory"""
|
100
|
+
if self._memory is None:
|
101
|
+
raise RuntimeError(
|
102
|
+
f"Memory access before assignment, please `set_memory` first!"
|
103
|
+
)
|
104
|
+
return self._memory
|
193
105
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
106
|
+
@property
|
107
|
+
def simulator(self):
|
108
|
+
"""The Simulator"""
|
109
|
+
if self._simulator is None:
|
110
|
+
raise RuntimeError(
|
111
|
+
f"Simulator access before assignment, please `set_simulator` first!"
|
112
|
+
)
|
113
|
+
return self._simulator
|
200
114
|
|
201
|
-
async def
|
202
|
-
"""
|
203
|
-
暂停Agent行为使Agent进入'pause'状态
|
204
|
-
Pause the Agent, making the agent 'pause'
|
115
|
+
async def generate_response(self, question: str) -> str:
|
116
|
+
"""生成回答
|
205
117
|
|
206
|
-
|
207
|
-
req = {'person_id': self.base['id'], 'schedules': []}
|
208
|
-
await self._client.person_service.SetSchedule(req)
|
209
|
-
self.Scheduler.unset_schedule()
|
210
|
-
self._st.trigger('pause')
|
118
|
+
基于智能体的记忆和当前状态,生成对问题的回答。
|
211
119
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
120
|
+
Args:
|
121
|
+
question: 需要回答的问题
|
122
|
+
|
123
|
+
Returns:
|
124
|
+
str: 智能体的回答
|
125
|
+
"""
|
126
|
+
dialog = []
|
127
|
+
|
128
|
+
# 添加系统提示
|
129
|
+
system_prompt = f"你是一个名叫{self._name}的{self._type.value}。请以第一人称的方式回答问题,保持回答简洁明了。"
|
130
|
+
dialog.append({"role": "system", "content": system_prompt})
|
131
|
+
|
132
|
+
# 添加记忆上下文
|
133
|
+
if self._memory:
|
134
|
+
relevant_memories = await self._memory.search(question)
|
135
|
+
if relevant_memories:
|
136
|
+
dialog.append(
|
137
|
+
{
|
138
|
+
"role": "system",
|
139
|
+
"content": f"基于以下记忆回答问题:\n{relevant_memories}",
|
140
|
+
}
|
141
|
+
)
|
142
|
+
|
143
|
+
# 添加用户问题
|
144
|
+
dialog.append({"role": "user", "content": question})
|
145
|
+
|
146
|
+
# 使用LLM生成回答
|
147
|
+
if not self._llm_client:
|
148
|
+
return "抱歉,我现在无法回答问题。"
|
149
|
+
|
150
|
+
response = await self._llm_client.atext_request(dialog) # type:ignore
|
151
|
+
|
152
|
+
# 记录采访历史
|
153
|
+
self._interview_history.append(
|
154
|
+
{
|
155
|
+
"timestamp": datetime.now().isoformat(),
|
156
|
+
"question": question,
|
157
|
+
"response": response,
|
158
|
+
}
|
159
|
+
)
|
218
160
|
|
219
|
-
|
220
|
-
"""
|
221
|
-
Agent执行入口
|
222
|
-
The Agent Run entrance
|
161
|
+
return response # type:ignore
|
223
162
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
- log (bool): 是否输出log信息, 默认为True. Whether console log message, default: True
|
228
|
-
"""
|
229
|
-
if self._soul == None:
|
230
|
-
print("Do not add soul yet. Try add_soul(UrbanLLM)")
|
231
|
-
await self.Step(log)
|
232
|
-
for i in range(0, round-1):
|
233
|
-
time.sleep(interval)
|
234
|
-
await self.Step(log)
|
235
|
-
|
236
|
-
async def Step(self, log:bool):
|
237
|
-
"""
|
238
|
-
单步Agent执行流
|
239
|
-
Single step entrance
|
240
|
-
(Not recommended, use Run() method)
|
163
|
+
def get_interview_history(self) -> List[Dict]:
|
164
|
+
"""获取采访历史记录"""
|
165
|
+
return self._interview_history
|
241
166
|
|
242
|
-
|
243
|
-
|
244
|
-
"""
|
245
|
-
|
246
|
-
# * 1. 模拟器时间更新
|
247
|
-
await self._simulator.GetTime()
|
248
|
-
# * 2. 拉取Agent最新状态
|
249
|
-
resp = await self._client.person_service.GetPerson({'person_id':self._id})
|
250
|
-
self.base = resp['base']
|
251
|
-
self.motion = resp['motion']
|
252
|
-
# * 3. Brain工作流
|
253
|
-
await self._brain.Run()
|
254
|
-
# * 4. Commond Controller工作流
|
255
|
-
commond = await self._cc.Run()
|
256
|
-
# * 5. State Transformer工作流
|
257
|
-
self._st.trigger(commond)
|
258
|
-
# * 6. Action Controller工作流
|
259
|
-
await self._ac.Run()
|
260
|
-
if log:
|
261
|
-
print(f"---------------------- SIM TIME: {self._simulator.time} ----------------------")
|
262
|
-
self.show_yourself()
|
263
|
-
|
264
|
-
def show_yourself(self):
|
265
|
-
"""
|
266
|
-
Log信息输出
|
267
|
-
Pring log message
|
268
|
-
"""
|
269
|
-
print(f"【State Message】: {self.state}")
|
270
|
-
motion_message = ''''''
|
271
|
-
motion_message += f'''行为状态: {self.motion['status']}, '''
|
272
|
-
if 'lane_position' in self.motion['position'].keys():
|
273
|
-
motion_message += f'''位置信息: lane-{self.motion['position']['lane_position']['lane_id']}'''
|
274
|
-
else:
|
275
|
-
motion_message += f'''位置信息: aoi-{self.motion['position']['aoi_position']['aoi_id']}'''
|
276
|
-
motion_message += f'''-[x: {self.motion['position']['xy_position']['x']}, y: {self.motion['position']['xy_position']['y']}]'''
|
277
|
-
print(f'【Simulator Motion Message】: \n{motion_message}')
|
278
|
-
print(self.Scheduler)
|
279
|
-
|
280
|
-
@property
|
281
|
-
def Image(self):
|
282
|
-
"""The Agent's Image"""
|
283
|
-
return self._image
|
284
|
-
|
285
|
-
@property
|
286
|
-
def Soul(self):
|
287
|
-
"""The Agent's Soul(UrbanLLM)"""
|
288
|
-
return self._soul
|
289
|
-
|
290
|
-
@property
|
291
|
-
def Brain(self):
|
292
|
-
"""The Agent's Brain"""
|
293
|
-
return self._brain
|
294
|
-
|
295
|
-
@property
|
296
|
-
def ActionController(self):
|
297
|
-
"""The Agents's ActionController"""
|
298
|
-
return self._ac
|
167
|
+
@abstractmethod
|
168
|
+
async def forward(self) -> None:
|
169
|
+
"""智能体行为逻辑"""
|
170
|
+
raise NotImplementedError
|
299
171
|
|
300
|
-
@property
|
301
|
-
def Scheduler(self):
|
302
|
-
"""The Agent's Scheduler"""
|
303
|
-
return self._brain.Memory.Working.scheduler
|
304
|
-
|
305
|
-
@property
|
306
|
-
def state(self):
|
307
|
-
"""The state of the Agent"""
|
308
|
-
return self._st.state
|
309
|
-
|
310
|
-
@property
|
311
|
-
def StateTransformer(self):
|
312
|
-
"""The StateTransformer of the Agent"""
|
313
|
-
return self._st
|
314
172
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
173
|
+
class CitizenAgent(Agent):
|
174
|
+
"""
|
175
|
+
CitizenAgent: 城市居民智能体类及其定义
|
176
|
+
"""
|
177
|
+
|
178
|
+
def __init__(
|
179
|
+
self,
|
180
|
+
name: str,
|
181
|
+
llm_client: Optional[LLM] = None,
|
182
|
+
simulator: Optional[Simulator] = None,
|
183
|
+
memory: Optional[Memory] = None,
|
184
|
+
) -> None:
|
185
|
+
super().__init__(
|
186
|
+
name,
|
187
|
+
AgentType.Citizen,
|
188
|
+
llm_client,
|
189
|
+
None,
|
190
|
+
simulator,
|
191
|
+
memory,
|
192
|
+
)
|
193
|
+
|
194
|
+
|
195
|
+
class InstitutionAgent(Agent):
|
196
|
+
"""
|
197
|
+
InstitutionAgent: 机构智能体类及其定义
|
198
|
+
"""
|
199
|
+
|
200
|
+
def __init__(
|
201
|
+
self,
|
202
|
+
name: str,
|
203
|
+
llm_client: Optional[LLM] = None,
|
204
|
+
simulator: Optional[Simulator] = None,
|
205
|
+
memory: Optional[Memory] = None,
|
206
|
+
) -> None:
|
207
|
+
super().__init__(
|
208
|
+
name,
|
209
|
+
AgentType.Institution,
|
210
|
+
llm_client,
|
211
|
+
None,
|
212
|
+
simulator,
|
213
|
+
memory,
|
214
|
+
)
|