pycityagent 2.0.0a49__cp310-cp310-macosx_11_0_arm64.whl → 2.0.0a51__cp310-cp310-macosx_11_0_arm64.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,41 @@
1
1
  import asyncio
2
+ import logging
2
3
  from typing import Optional
3
4
 
4
5
  import numpy as np
5
- from pycityagent import Simulator, InstitutionAgent
6
- from pycityagent.llm.llm import LLM
6
+
7
+ from pycityagent import InstitutionAgent, Simulator
7
8
  from pycityagent.economy import EconomyClient
8
- from pycityagent.message import Messager
9
+ from pycityagent.llm.llm import LLM
9
10
  from pycityagent.memory import Memory
10
- from pycityagent.workflow.tool import ExportMlflowMetrics
11
- import logging
11
+ from pycityagent.message import Messager
12
+ from pycityagent.tools import ExportMlflowMetrics
12
13
 
13
14
  logger = logging.getLogger("pycityagent")
14
15
 
16
+
15
17
  class NBSAgent(InstitutionAgent):
16
18
  export_metrics = ExportMlflowMetrics(log_batch_size=3)
17
-
18
- def __init__(self,
19
- name: str,
20
- llm_client: Optional[LLM] = None,
21
- simulator: Optional[Simulator] = None,
22
- memory: Optional[Memory] = None,
23
- economy_client: Optional[EconomyClient] = None,
24
- messager: Optional[Messager] = None,
25
- avro_file: Optional[dict] = None,
26
- ) -> None:
27
- super().__init__(name=name, llm_client=llm_client, simulator=simulator, memory=memory, economy_client=economy_client, messager=messager, avro_file=avro_file)
19
+
20
+ def __init__(
21
+ self,
22
+ name: str,
23
+ llm_client: Optional[LLM] = None,
24
+ simulator: Optional[Simulator] = None,
25
+ memory: Optional[Memory] = None,
26
+ economy_client: Optional[EconomyClient] = None,
27
+ messager: Optional[Messager] = None,
28
+ avro_file: Optional[dict] = None,
29
+ ) -> None:
30
+ super().__init__(
31
+ name=name,
32
+ llm_client=llm_client,
33
+ simulator=simulator,
34
+ memory=memory,
35
+ economy_client=economy_client,
36
+ messager=messager,
37
+ avro_file=avro_file,
38
+ )
28
39
  self.initailzed = False
29
40
  self.last_time_trigger = None
30
41
  self.time_diff = 30 * 24 * 60 * 60
@@ -32,6 +43,7 @@ class NBSAgent(InstitutionAgent):
32
43
  self.num_labor_hours = 168
33
44
  self.productivity_per_labor = 1
34
45
  self.price = 1
46
+
35
47
  async def month_trigger(self):
36
48
  now_time = await self.simulator.get_time()
37
49
  if self.last_time_trigger is None:
@@ -41,46 +53,80 @@ class NBSAgent(InstitutionAgent):
41
53
  self.last_time_trigger = now_time
42
54
  return True
43
55
  return False
44
-
56
+
45
57
  async def gather_messages(self, agent_ids, content):
46
58
  infos = await super().gather_messages(agent_ids, content)
47
- return [info['content'] for info in infos]
59
+ return [info["content"] for info in infos]
48
60
 
49
61
  async def forward(self):
50
62
  if await self.month_trigger():
51
63
  citizens = await self.memory.get("citizens")
52
64
  while True:
53
- agents_forward = await self.gather_messages(citizens, 'forward')
65
+ agents_forward = await self.gather_messages(citizens, "forward")
54
66
  if np.all(np.array(agents_forward) > self.forward_times):
55
67
  break
56
68
  await asyncio.sleep(1)
57
69
  work_propensity = await self.gather_messages(citizens, "work_propensity")
58
- working_hours = np.mean(work_propensity)*self.num_labor_hours
70
+ working_hours = np.mean(work_propensity) * self.num_labor_hours
59
71
  firm_id = await self.memory.get("firm_id")
60
72
  price = await self.economy_client.get(firm_id, "price")
61
73
  prices = await self.economy_client.get(self._agent_id, "prices")
62
74
  initial_price = prices[0]
63
- nominal_gdp = working_hours*len(citizens)*self.productivity_per_labor*price
64
- real_gdp = working_hours*len(citizens)*self.productivity_per_labor*initial_price
65
- await self.economy_client.update(self._agent_id, 'nominal_gdp', [nominal_gdp], mode='merge')
66
- await self.economy_client.update(self._agent_id, 'real_gdp', [real_gdp], mode='merge')
67
- await self.economy_client.update(self._agent_id, 'working_hours', [working_hours], mode='merge')
68
- await self.economy_client.update(self._agent_id, 'prices', [price], mode='merge')
69
- depression = await self.gather_messages(citizens, 'depression')
75
+ nominal_gdp = (
76
+ working_hours * len(citizens) * self.productivity_per_labor * price
77
+ )
78
+ real_gdp = (
79
+ working_hours
80
+ * len(citizens)
81
+ * self.productivity_per_labor
82
+ * initial_price
83
+ )
84
+ await self.economy_client.update(
85
+ self._agent_id, "nominal_gdp", [nominal_gdp], mode="merge"
86
+ )
87
+ await self.economy_client.update(
88
+ self._agent_id, "real_gdp", [real_gdp], mode="merge"
89
+ )
90
+ await self.economy_client.update(
91
+ self._agent_id, "working_hours", [working_hours], mode="merge"
92
+ )
93
+ await self.economy_client.update(
94
+ self._agent_id, "prices", [price], mode="merge"
95
+ )
96
+ depression = await self.gather_messages(citizens, "depression")
70
97
  depression = np.mean(depression)
71
- await self.economy_client.update(self._agent_id, 'depression', [depression], mode='merge')
72
- consumption_currency = await self.gather_messages(citizens, 'consumption_currency')
98
+ await self.economy_client.update(
99
+ self._agent_id, "depression", [depression], mode="merge"
100
+ )
101
+ consumption_currency = await self.gather_messages(
102
+ citizens, "consumption_currency"
103
+ )
73
104
  consumption_currency = np.mean(consumption_currency)
74
- await self.economy_client.update(self._agent_id, 'consumption_currency', [consumption_currency], mode='merge')
75
- income_currency = await self.gather_messages(citizens, 'income_currency')
105
+ await self.economy_client.update(
106
+ self._agent_id,
107
+ "consumption_currency",
108
+ [consumption_currency],
109
+ mode="merge",
110
+ )
111
+ income_currency = await self.gather_messages(citizens, "income_currency")
76
112
  income_currency = np.mean(income_currency)
77
- await self.economy_client.update(self._agent_id, 'income_currency', [income_currency], mode='merge')
113
+ await self.economy_client.update(
114
+ self._agent_id, "income_currency", [income_currency], mode="merge"
115
+ )
78
116
  self.forward_times += 1
79
117
  for uuid in citizens:
80
- await self.send_message_to_agent(uuid, f"nbs_forward@{self.forward_times}")
118
+ await self.send_message_to_agent(
119
+ uuid, f"nbs_forward@{self.forward_times}"
120
+ )
81
121
 
82
- metrics = {'nominal_gdp': nominal_gdp, 'working_hours': working_hours, 'price': price,
83
- 'depression': depression, 'consumption': consumption_currency, 'income': income_currency}
122
+ metrics = {
123
+ "nominal_gdp": nominal_gdp,
124
+ "working_hours": working_hours,
125
+ "price": price,
126
+ "depression": depression,
127
+ "consumption": consumption_currency,
128
+ "income": income_currency,
129
+ }
84
130
  for k, v in metrics.items():
85
131
  await self.export_metrics(
86
132
  metric={
@@ -89,4 +135,4 @@ class NBSAgent(InstitutionAgent):
89
135
  "step": self.forward_times,
90
136
  },
91
137
  clear_cache=True,
92
- )
138
+ )
@@ -1,22 +1,27 @@
1
1
  import asyncio
2
2
  import json
3
+ import logging
3
4
  from typing import Optional
4
- from pycityagent import Simulator, CitizenAgent
5
+
6
+ from pycityagent import CitizenAgent, Simulator
5
7
  from pycityagent.agent import Agent
6
- from pycityagent.llm.llm import LLM
7
8
  from pycityagent.economy import EconomyClient
8
- from pycityagent.message import Messager
9
+ from pycityagent.llm.llm import LLM
9
10
  from pycityagent.memory import Memory
10
- from pycityagent.workflow.tool import UpdateWithSimulator
11
+ from pycityagent.message import Messager
11
12
  from pycityagent.workflow import Block
12
- from .blocks import CognitionBlock, EconomyBlock, MobilityBlock, NeedsBlock, OtherBlock, PlanBlock, SocialBlock
13
+ from pycityagent.tools import UpdateWithSimulator
14
+
15
+ from .blocks import (CognitionBlock, EconomyBlock, MobilityBlock, NeedsBlock,
16
+ OtherBlock, PlanBlock, SocialBlock)
13
17
  from .blocks.economy_block import MonthPlanBlock
14
- import logging
15
18
 
16
19
  logger = logging.getLogger("pycityagent")
17
20
 
21
+
18
22
  class PlanAndActionBlock(Block):
19
23
  """主动工作流"""
24
+
20
25
  longTermDecisionBlock: MonthPlanBlock
21
26
  needsBlock: NeedsBlock
22
27
  planBlock: PlanBlock
@@ -25,48 +30,77 @@ class PlanAndActionBlock(Block):
25
30
  economyBlock: EconomyBlock
26
31
  otherBlock: OtherBlock
27
32
 
28
- def __init__(self, agent: Agent, llm: LLM, memory: Memory, simulator: Simulator, economy_client: EconomyClient):
29
- super().__init__(name="plan_and_action_block", llm=llm, memory=memory, simulator=simulator)
33
+ def __init__(
34
+ self,
35
+ agent: Agent,
36
+ llm: LLM,
37
+ memory: Memory,
38
+ simulator: Simulator,
39
+ economy_client: EconomyClient,
40
+ ):
41
+ super().__init__(
42
+ name="plan_and_action_block", llm=llm, memory=memory, simulator=simulator
43
+ )
30
44
  self._agent = agent
31
- self.longTermDecisionBlock = MonthPlanBlock(llm=llm, memory=memory, simulator=simulator, economy_client=economy_client)
45
+ self.longTermDecisionBlock = MonthPlanBlock(
46
+ llm=llm, memory=memory, simulator=simulator, economy_client=economy_client
47
+ )
32
48
  self.needsBlock = NeedsBlock(llm=llm, memory=memory, simulator=simulator)
33
49
  self.planBlock = PlanBlock(llm=llm, memory=memory, simulator=simulator)
34
50
  self.mobilityBlock = MobilityBlock(llm=llm, memory=memory, simulator=simulator)
35
- self.socialBlock = SocialBlock(agent=self, llm=llm, memory=memory, simulator=simulator)
36
- self.economyBlock = EconomyBlock(llm=llm, memory=memory, simulator=simulator, economy_client=economy_client)
51
+ self.socialBlock = SocialBlock(
52
+ agent=self, llm=llm, memory=memory, simulator=simulator
53
+ )
54
+ self.economyBlock = EconomyBlock(
55
+ llm=llm, memory=memory, simulator=simulator, economy_client=economy_client
56
+ )
37
57
  self.otherBlock = OtherBlock(llm=llm, memory=memory)
38
58
 
39
59
  async def check_and_update_step(self):
40
- status = await self.memory.get('status')
60
+ status = await self.memory.get("status")
41
61
  if status == 2:
42
62
  # 正在运动
43
63
  logger.info("Agent is moving")
44
64
  await asyncio.sleep(1)
45
65
  return False
46
-
66
+
47
67
  # 获取上一步信息
48
68
  current_step = await self.memory.get("current_step")
49
- if current_step['intention'] == "" or current_step['type'] == "":
69
+ if current_step["intention"] == "" or current_step["type"] == "":
50
70
  # 没有上一步,直接返回
51
71
  return True
52
72
  time_now = int(await self.simulator.get_time())
53
- step_start_time = current_step['start_time']
54
- step_consumed_time = current_step['evaluation']['consumed_time']
55
- time_end_plan = step_start_time + int(step_consumed_time)*60
73
+ step_start_time = current_step["start_time"]
74
+ step_consumed_time = current_step["evaluation"]["consumed_time"]
75
+ time_end_plan = step_start_time + int(step_consumed_time) * 60
56
76
  if time_now >= time_end_plan:
57
77
  # 上一步执行完成
58
78
  current_plan = await self.memory.get("current_plan")
59
- current_step['evaluation']['consumed_time'] = (time_now - step_start_time)/60
60
- current_step_index = next((i for i, step in enumerate(current_plan["steps"]) if step['intention'] == current_step['intention'] and step['type'] == current_step['type']), None)
79
+ current_step["evaluation"]["consumed_time"] = (
80
+ time_now - step_start_time
81
+ ) / 60
82
+ current_step_index = next(
83
+ (
84
+ i
85
+ for i, step in enumerate(current_plan["steps"])
86
+ if step["intention"] == current_step["intention"]
87
+ and step["type"] == current_step["type"]
88
+ ),
89
+ None,
90
+ )
61
91
  current_plan["steps"][current_step_index] = current_step
62
92
  await self.memory.update("current_plan", current_plan)
63
- if current_step_index is not None and current_step_index + 1 < len(current_plan["steps"]):
93
+ if current_step_index is not None and current_step_index + 1 < len(
94
+ current_plan["steps"]
95
+ ):
64
96
  next_step = current_plan["steps"][current_step_index + 1]
65
97
  await self.memory.update("current_step", next_step)
66
98
  else:
67
99
  # 标记计划完成
68
100
  current_plan["completed"] = True
69
- current_plan["end_time"] = await self.simulator.get_time(format_time=True)
101
+ current_plan["end_time"] = await self.simulator.get_time(
102
+ format_time=True
103
+ )
70
104
  await self.memory.update("current_plan", current_plan)
71
105
  await self.memory.update("current_step", {"intention": "", "type": ""})
72
106
  logger.info("Current plan execution completed.\n")
@@ -80,7 +114,7 @@ class PlanAndActionBlock(Block):
80
114
  # 检测上一步是否执行完成
81
115
  if not await self.check_and_update_step():
82
116
  return
83
-
117
+
84
118
  # 长期决策
85
119
  await self.longTermDecisionBlock.forward()
86
120
 
@@ -102,58 +136,92 @@ class PlanAndActionBlock(Block):
102
136
  if current_step and current_step.get("type") and current_step.get("intention"):
103
137
  step_type = current_step.get("type")
104
138
  position = await self.memory.get("position")
105
- if 'aoi_position' in position:
106
- current_step['position'] = position['aoi_position']['aoi_id']
107
- current_step['start_time'] = int(await self.simulator.get_time())
108
- logger.info(f"Executing step: {current_step['intention']} - Type: {step_type}")
139
+ if "aoi_position" in position:
140
+ current_step["position"] = position["aoi_position"]["aoi_id"]
141
+ current_step["start_time"] = int(await self.simulator.get_time())
142
+ logger.info(
143
+ f"Executing step: {current_step['intention']} - Type: {step_type}"
144
+ )
109
145
  result = None
110
146
  if step_type == "mobility":
111
- result = await self.mobilityBlock.forward(current_step, execution_context)
147
+ result = await self.mobilityBlock.forward(
148
+ current_step, execution_context
149
+ )
112
150
  elif step_type == "social":
113
151
  result = await self.socialBlock.forward(current_step, execution_context)
114
152
  elif step_type == "economy":
115
- result = await self.economyBlock.forward(current_step, execution_context)
153
+ result = await self.economyBlock.forward(
154
+ current_step, execution_context
155
+ )
116
156
  elif step_type == "other":
117
157
  result = await self.otherBlock.forward(current_step, execution_context)
118
158
  if result != None:
119
159
  logger.info(f"Execution result: {result}")
120
- current_step['evaluation'] = result
121
-
160
+ current_step["evaluation"] = result
161
+
122
162
  # 更新current_step信息,plan信息以及execution_context信息
123
- current_step_index = next((i for i, step in enumerate(current_plan["steps"]) if step['intention'] == current_step['intention'] and step['type'] == current_step['type']), None)
163
+ current_step_index = next(
164
+ (
165
+ i
166
+ for i, step in enumerate(current_plan["steps"])
167
+ if step["intention"] == current_step["intention"]
168
+ and step["type"] == current_step["type"]
169
+ ),
170
+ None,
171
+ )
124
172
  current_plan["steps"][current_step_index] = current_step
125
173
  await self.memory.update("current_step", current_step)
126
174
  await self.memory.update("current_plan", current_plan)
127
175
  await self.memory.update("execution_context", execution_context)
128
176
 
177
+
129
178
  class MindBlock(Block):
130
179
  """认知工作流"""
180
+
131
181
  cognitionBlock: CognitionBlock
132
182
 
133
183
  def __init__(self, llm: LLM, memory: Memory, simulator: Simulator):
134
184
  super().__init__(name="mind_block", llm=llm, memory=memory, simulator=simulator)
135
- self.cognitionBlock = CognitionBlock(llm=llm, memory=memory, simulator=simulator)
185
+ self.cognitionBlock = CognitionBlock(
186
+ llm=llm, memory=memory, simulator=simulator
187
+ )
136
188
 
137
189
  async def forward(self):
138
190
  await self.cognitionBlock.forward()
139
191
 
192
+
140
193
  class SocietyAgent(CitizenAgent):
141
194
  mindBlock: MindBlock
142
195
  planAndActionBlock: PlanAndActionBlock
143
196
  update_with_sim = UpdateWithSimulator()
144
197
 
145
- def __init__(self,
146
- name: str,
147
- llm_client: Optional[LLM] = None,
148
- simulator: Optional[Simulator] = None,
149
- memory: Optional[Memory] = None,
150
- economy_client: Optional[EconomyClient] = None,
151
- ) -> None:
152
- super().__init__(name=name, llm_client=llm_client, simulator=simulator, memory=memory, economy_client=economy_client)
153
- self.mindBlock = MindBlock(llm=self._llm_client, memory=self._memory, simulator=self._simulator)
154
- self.planAndActionBlock = PlanAndActionBlock(agent=self, llm=self._llm_client, memory=self._memory, simulator=self._simulator, economy_client=self._economy_client)
155
- self.step_count = -1
156
-
198
+ def __init__(
199
+ self,
200
+ name: str,
201
+ llm_client: Optional[LLM] = None,
202
+ simulator: Optional[Simulator] = None,
203
+ memory: Optional[Memory] = None,
204
+ economy_client: Optional[EconomyClient] = None,
205
+ ) -> None:
206
+ super().__init__(
207
+ name=name,
208
+ llm_client=llm_client,
209
+ simulator=simulator,
210
+ memory=memory,
211
+ economy_client=economy_client,
212
+ )
213
+ self.mindBlock = MindBlock(
214
+ llm=self._llm_client, memory=self._memory, simulator=self._simulator
215
+ )
216
+ self.planAndActionBlock = PlanAndActionBlock(
217
+ agent=self,
218
+ llm=self._llm_client,
219
+ memory=self._memory,
220
+ simulator=self._simulator,
221
+ economy_client=self._economy_client,
222
+ )
223
+ self.step_count = -1
224
+
157
225
  # Main workflow
158
226
  async def forward(self):
159
227
  logger.info(f"Agent {self._uuid} forward")
@@ -166,7 +234,7 @@ class SocietyAgent(CitizenAgent):
166
234
  await asyncio.gather(*task_list)
167
235
 
168
236
  async def process_agent_chat_response(self, payload: dict) -> str:
169
- if payload['type'] == 'social':
237
+ if payload["type"] == "social":
170
238
  resp = f"Agent {self._uuid} received agent chat response: {payload}"
171
239
  logger.info(resp)
172
240
  try:
@@ -174,9 +242,9 @@ class SocietyAgent(CitizenAgent):
174
242
  sender_id = payload.get("from")
175
243
  if not sender_id:
176
244
  return ""
177
-
245
+
178
246
  raw_content = payload.get("content", "")
179
-
247
+
180
248
  # Parse message content
181
249
  try:
182
250
  message_data = json.loads(raw_content)
@@ -185,32 +253,34 @@ class SocietyAgent(CitizenAgent):
185
253
  except (json.JSONDecodeError, TypeError, KeyError):
186
254
  content = raw_content
187
255
  propagation_count = 1
188
-
256
+
189
257
  if not content:
190
258
  return ""
191
-
259
+
192
260
  # Get chat histories and ensure proper format
193
261
  chat_histories = await self._memory.get("chat_histories") or {}
194
262
  if not isinstance(chat_histories, dict):
195
263
  chat_histories = {}
196
-
264
+
197
265
  # Update chat history with received message
198
266
  if sender_id not in chat_histories:
199
267
  chat_histories[sender_id] = ""
200
268
  if chat_histories[sender_id]:
201
269
  chat_histories[sender_id] += ","
202
270
  chat_histories[sender_id] += f"them: {content}"
203
-
271
+
204
272
  # Check propagation limit
205
273
  if propagation_count > 5:
206
274
  await self._memory.update("chat_histories", chat_histories)
207
- logger.info(f"Message propagation limit reached ({propagation_count} > 5), stopping propagation")
275
+ logger.info(
276
+ f"Message propagation limit reached ({propagation_count} > 5), stopping propagation"
277
+ )
208
278
  return ""
209
-
279
+
210
280
  # Get relationship score
211
281
  relationships = await self._memory.get("relationships") or {}
212
282
  relationship_score = relationships.get(sender_id, 50)
213
-
283
+
214
284
  # Decision prompt
215
285
  should_respond_prompt = f"""Based on:
216
286
  - Received message: "{content}"
@@ -230,10 +300,15 @@ class SocietyAgent(CitizenAgent):
230
300
 
231
301
  Answer only YES or NO."""
232
302
 
233
- should_respond = await self._llm_client.atext_request([
234
- {"role": "system", "content": "You are helping decide whether to respond to a message."},
235
- {"role": "user", "content": should_respond_prompt}
236
- ])
303
+ should_respond = await self._llm_client.atext_request(
304
+ [
305
+ {
306
+ "role": "system",
307
+ "content": "You are helping decide whether to respond to a message.",
308
+ },
309
+ {"role": "user", "content": should_respond_prompt},
310
+ ]
311
+ )
237
312
 
238
313
  if should_respond.strip().upper() != "YES":
239
314
  await self._memory.update("chat_histories", chat_histories)
@@ -258,34 +333,42 @@ class SocietyAgent(CitizenAgent):
258
333
 
259
334
  Response should be ONLY the message text, no explanations."""
260
335
 
261
- response = await self._llm_client.atext_request([
262
- {"role": "system", "content": "You are helping generate a chat response."},
263
- {"role": "user", "content": response_prompt}
264
- ])
336
+ response = await self._llm_client.atext_request(
337
+ [
338
+ {
339
+ "role": "system",
340
+ "content": "You are helping generate a chat response.",
341
+ },
342
+ {"role": "user", "content": response_prompt},
343
+ ]
344
+ )
265
345
 
266
346
  if response:
267
347
  # Update chat history with response
268
348
  chat_histories[sender_id] += f",me: {response}"
269
349
  await self._memory.update("chat_histories", chat_histories)
270
-
350
+
271
351
  # Send response
272
- serialized_response = json.dumps({
273
- "content": response,
274
- "propagation_count": propagation_count + 1
275
- }, ensure_ascii=False)
352
+ serialized_response = json.dumps(
353
+ {
354
+ "content": response,
355
+ "propagation_count": propagation_count + 1,
356
+ },
357
+ ensure_ascii=False,
358
+ )
276
359
  await self.send_message_to_agent(sender_id, serialized_response)
277
- logger.info('sender_id',sender_id)
278
- logger.info('message',serialized_response)
360
+ logger.info("sender_id", sender_id)
361
+ logger.info("message", serialized_response)
279
362
  return response
280
363
 
281
364
  except Exception as e:
282
365
  logger.warning(f"Error in process_agent_chat_response: {str(e)}")
283
366
  return ""
284
367
  else:
285
- content = payload['content']
368
+ content = payload["content"]
286
369
  key, value = content.split("@")
287
- if '.' in value:
370
+ if "." in value:
288
371
  value = float(value)
289
372
  else:
290
373
  value = int(value)
291
- await self.memory.update(key, value)
374
+ await self.memory.update(key, value)
@@ -48,7 +48,7 @@ class AgentGroup:
48
48
  mlflow_run_id: str,
49
49
  embedding_model: Embeddings,
50
50
  logging_level: int,
51
- agent_config_file: Union[str, list[str]] = None,
51
+ agent_config_file: Optional[Union[str, list[str]]] = None,
52
52
  ):
53
53
  logger.setLevel(logging_level)
54
54
  self._uuid = str(uuid.uuid4())
@@ -163,7 +163,7 @@ class AgentGroup:
163
163
  agent.memory.set_faiss_query(self.faiss_query)
164
164
  if self.embedding_model is not None:
165
165
  agent.memory.set_embedding_model(self.embedding_model)
166
- if self.agent_config_file[i]:
166
+ if self.agent_config_file is not None and self.agent_config_file[i]:
167
167
  agent.load_from_file(self.agent_config_file[i])
168
168
  self.agents.append(agent)
169
169
  self.id2agent[agent._uuid] = agent