laverdes commited on
Commit
6b4ac5f
·
verified ·
1 Parent(s): f64da7d

fix: indentation

Browse files
Files changed (1) hide show
  1. basic_agent.py +33 -33
basic_agent.py CHANGED
@@ -159,39 +159,39 @@ class ToolAgent:
159
 
160
  def chat(self, query:str, metadata):
161
  """Perform a single step in the conversation with the tool agent executor."""
162
- if metadata is None:
163
- metadata = {}
164
-
165
- with_attachments = False
166
- query_message = HumanMessage(content=query)
167
-
168
- if "image_path" in metadata:
169
-
170
- # Create a HumanMessage with image content
171
- query_message = HumanMessage(
172
- content=[
173
- {"type": "text", "text": query},
174
- {"type": "text", "text": f"image_path: {metadata['image_path']}"},
175
- ]
176
- )
177
- with_attachments = True
178
-
179
- user_message = {'role': 'user', 'content': query if not with_attachments else query_message}
180
- print_conversation([user_message])
181
-
182
- response = self.executor.invoke({
183
- "query": query if not with_attachments else query_message,
184
- })
185
- response_message = {'role': 'assistant', 'content': response}
186
- print_conversation([response_message])
187
-
188
- final_answer = generate_final_answer({
189
- 'query': query,
190
- 'response': response,
191
- })
192
- final_answer_message = {'role': 'Final Answer', 'content': final_answer}
193
- print_conversation([final_answer_message])
194
- return final_answer
195
 
196
 
197
  def invoke(self, q_data):
 
159
 
160
  def chat(self, query:str, metadata):
161
  """Perform a single step in the conversation with the tool agent executor."""
162
+ if metadata is None:
163
+ metadata = {}
164
+
165
+ with_attachments = False
166
+ query_message = HumanMessage(content=query)
167
+
168
+ if "image_path" in metadata:
169
+
170
+ # Create a HumanMessage with image content
171
+ query_message = HumanMessage(
172
+ content=[
173
+ {"type": "text", "text": query},
174
+ {"type": "text", "text": f"image_path: {metadata['image_path']}"},
175
+ ]
176
+ )
177
+ with_attachments = True
178
+
179
+ user_message = {'role': 'user', 'content': query if not with_attachments else query_message}
180
+ print_conversation([user_message])
181
+
182
+ response = self.executor.invoke({
183
+ "query": query if not with_attachments else query_message,
184
+ })
185
+ response_message = {'role': 'assistant', 'content': response}
186
+ print_conversation([response_message])
187
+
188
+ final_answer = generate_final_answer({
189
+ 'query': query,
190
+ 'response': response,
191
+ })
192
+ final_answer_message = {'role': 'Final Answer', 'content': final_answer}
193
+ print_conversation([final_answer_message])
194
+ return final_answer
195
 
196
 
197
  def invoke(self, q_data):