Markiian Tsalyk commited on
Commit
b477d60
·
1 Parent(s): 783d369
Files changed (2) hide show
  1. llama_index_agent.py +1 -3
  2. tools.py +2 -4
llama_index_agent.py CHANGED
@@ -154,9 +154,7 @@ class LlamaIndexAgent:
154
  response = self.agent.chat(query_text).response
155
  except:
156
  response = ""
157
- final_response = self.small_agent.chat(
158
- f"Question: {query_text}\nResponse: {response}"
159
- )
160
 
161
  return final_response.response
162
 
 
154
  response = self.agent.chat(query_text).response
155
  except:
156
  response = ""
157
+ final_response = self.small_agent.chat(f"Response: {response}")
 
 
158
 
159
  return final_response.response
160
 
tools.py CHANGED
@@ -300,20 +300,18 @@ def pandas_column_sum(
300
  return sum(pandas_column_values)
301
 
302
 
303
- def final_answer(query: str, answer: str, **kwargs) -> str:
304
  """
305
  Prepare the final answer for the user. It should be always used as a last step.
306
 
307
  Args:
308
- query: The initial query of the user
309
  answer: The answer to format and return to the user
310
  Return:
311
  The final answer.
312
  """
313
  return f"""
314
- User query: {query}
315
  Final answer from agent: {answer}
316
- Adapt final answer to user request.
317
  Final answer should be a number or as few words as possible or a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
318
  There might be requested exact number, then you need to compress the output so that it was only number without any comments or explanations (float or integer).
319
  And on the other hand, the question might request some exact string value. Don't explain it, just return this value (For example, insted of `In response to the question, desired person is X` return only `X`)
 
300
  return sum(pandas_column_values)
301
 
302
 
303
+ def final_answer(answer: str, **kwargs) -> str:
304
  """
305
  Prepare the final answer for the user. It should be always used as a last step.
306
 
307
  Args:
 
308
  answer: The answer to format and return to the user
309
  Return:
310
  The final answer.
311
  """
312
  return f"""
 
313
  Final answer from agent: {answer}
314
+ Make final answer as short as possible.
315
  Final answer should be a number or as few words as possible or a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
316
  There might be requested exact number, then you need to compress the output so that it was only number without any comments or explanations (float or integer).
317
  And on the other hand, the question might request some exact string value. Don't explain it, just return this value (For example, insted of `In response to the question, desired person is X` return only `X`)