5
5
import aisuite as ai
6
6
7
7
from enum import Enum
8
+ from copy import deepcopy
8
9
from typing import List , Callable
9
10
from faker import Faker
10
11
from .Interaction import Interaction
@@ -123,9 +124,9 @@ def __init__(self, **kwargs):
123
124
self .agent_informations ["bio" ] = Agent ._generate_agent_bio (self .agent_informations )
124
125
125
126
self ._interaction_manager .register_agent (self )
126
- self ._act_prompt = Agent ._default_act_prompt
127
+ self ._act_prompt = deepcopy ( Agent ._default_act_prompt )
127
128
128
- self ._actions = Agent ._default_actions
129
+ self ._actions = deepcopy ( Agent ._default_actions )
129
130
self ._actions ["TALK" ]["function" ] = self ._talk_action_function
130
131
self ._actions ["THINK" ]["function" ] = self ._think_action_function
131
132
@@ -271,7 +272,6 @@ def act(self) -> str:
271
272
response = llm_client .chat .completions .create (
272
273
model = f"{ config .llm_provider } :{ config .llm_model } " ,
273
274
messages = [
274
- {"role" : "system" , "content" : "You are a helpful assistant." },
275
275
{"role" : "user" , "content" : prompt },
276
276
],
277
277
temperature = 0.4 ,
@@ -283,19 +283,6 @@ def act(self) -> str:
283
283
if actions [0 ] in self ._actions :
284
284
return self ._actions [actions [0 ]]["function" ](* actions [1 :])
285
285
286
- # if actions[0] == "TALK":
287
- # if len(actions) < 3:
288
- # raise RuntimeError(f"Received a TALK action with less than 3 arguments: {actions}")
289
-
290
- # if (receiver := self._interaction_manager.get_agent(actions[1])) is None:
291
- # raise RuntimeError(f"Received a TALK action with an invalid agent ID: {actions[1]}")
292
-
293
- # return self.talk_to(receiver, actions[2])
294
-
295
- # elif actions[0] == "THINK":
296
- # # NOTE: This is a self-interaction, but maybe we should add a way to handle self-thinking.
297
- # return self._interaction_manager.record_interaction(self, self, actions[1])
298
-
299
286
raise RuntimeError (f"Invalid action: '{ actions [0 ]} '. Received output: { response .choices [0 ].message .content } " )
300
287
301
288
def dump (self ) -> dict :
@@ -505,6 +492,13 @@ def wrapper(*args, **kwargs):
505
492
self ._actions [name ] = action_descriptor
506
493
self ._actions [name ]["function" ] = standardize_action_output (action_function )
507
494
495
+ def reset (self ) -> None :
496
+ """
497
+ Reset the agent's state.
498
+ """
499
+ self ._interaction_manager .reset_agent (self )
500
+ self .storage = {}
501
+
508
502
509
503
if __name__ == "__main__" :
510
504
0 commit comments