@@ -74,7 +74,27 @@ def __init__(self, model_name: str, goal: str, memory_len: int = 10, api_url=Non
7474 self .memory_len = memory_len
7575 self .logger = logging .getLogger ("REACT-agent" )
7676 self .update_instructions (goal .lower ())
77-
77+ self .prompts = []
78+ self .states = []
79+ self .responses = []
80+
81+ def get_prompts (self ) -> list :
82+ """
83+ Returns the list of prompts sent to the LLM."""
84+ return self .prompts
85+
86+ def get_responses (self ) -> list :
87+ """
88+ Returns the list of responses received from the LLM. Only Stage 2 responses are included.
89+ """
90+ return self .responses
91+
92+ def get_states (self ) -> list :
93+ """
94+ Returns the list of states received from the LLM. In JSON format.
95+ """
96+ return self .states
97+
7898 def update_instructions (self , new_goal : str ) -> None :
7999 template = jinja2 .Environment ().from_string (self .config ['prompts' ]['INSTRUCTIONS_TEMPLATE' ])
80100 self .instructions = template .render (goal = new_goal )
@@ -141,6 +161,8 @@ def parse_response(self, llm_response: str, state: Observation.state):
141161
142162
143163 def get_action_from_obs_react (self , observation : Observation , memory_buf : list ) -> tuple :
164+ self .states .append (observation .state .as_json ())
165+
144166 status_prompt = create_status_from_state (observation .state )
145167 Q1 = self .config ['questions' ][0 ]['text' ]
146168 Q4 = self .config ['questions' ][3 ]['text' ]
@@ -168,8 +190,10 @@ def get_action_from_obs_react(self, observation: Observation, memory_buf: list)
168190 {"role" : "user" , "content" : memory_prompt },
169191 {"role" : "user" , "content" : Q4 },
170192 ]
171-
193+ self .prompts .append (messages )
194+
172195 response = self .openai_query (messages , max_tokens = 80 , fmt = {"type" : "json_object" })
196+ self .responses .append (response )
173197 self .logger .info (f"(Stage 2) Response from LLM: { response } " )
174198 print (f"(Stage 2) Response from LLM: { response } " )
175199 return self .parse_response (response , observation .state )
0 commit comments