Nguyen Nhu Trung commited on
Commit
1c89ca6
·
1 Parent(s): eea473e

update tool description -- increase delay

Browse files
Files changed (2) hide show
  1. agent.py +12 -11
  2. app.py +1 -1
agent.py CHANGED
@@ -43,16 +43,16 @@ tavily_extract_tool = TavilyExtract()
43
 
44
 
45
  @tool
46
- def read_excel_file(excel_file_path: str) -> str:
47
  """Read the content of excel file.
48
 
49
  Args:
50
- excel_file_path: path to excel file
51
  """
52
  # Load the Excel file using pandas
53
  try:
54
  # Read the Excel file
55
- df = pd.read_excel(excel_file_path, sheet_name=None) # sheet_name=None loads all sheets
56
 
57
  # Convert each sheet to a dictionary of rows
58
  json_output = {}
@@ -68,14 +68,14 @@ def read_excel_file(excel_file_path: str) -> str:
68
 
69
 
70
  @tool
71
- def transcribe_audio(file_path: str) -> str:
72
  """Transcribe the audio file into text.
73
 
74
  Args:
75
- file_path: path to audio file
76
  """
77
  config = aai.TranscriptionConfig(speech_model=aai.SpeechModel.best)
78
- transcript = aai.Transcriber(config=config).transcribe(file_path)
79
  if transcript.status == "error":
80
  raise RuntimeError(f"Transcription failed: {transcript.error}")
81
  return f"Here is the transcript: {transcript.text}"
@@ -92,6 +92,7 @@ def wiki_search(query: str) -> str:
92
  f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
93
  for doc in search_docs
94
  ])
 
95
  return {"wiki_results": formatted_search_docs}
96
 
97
  # @tool
@@ -122,8 +123,8 @@ sys_msg = SystemMessage(content=system_prompt)
122
 
123
  tools = [
124
  wiki_search,
125
- # tavily_search_tool,
126
- # tavily_extract_tool,
127
  repl_tool,
128
  read_excel_file,
129
  transcribe_audio
@@ -168,9 +169,9 @@ def get_answer(query):
168
 
169
  if __name__ == "__main__":
170
  question = "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?"
171
- question = "Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order."
172
- question = "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?"
173
- question = "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations."
174
  question = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
175
  # getmessages = [HumanMessage(content=question)]
176
  # messages = graph.invoke({"messages": messages})
 
43
 
44
 
45
  @tool
46
+ def read_excel_file(file_name: str) -> str:
47
  """Read the content of excel file.
48
 
49
  Args:
50
+ file_name: name of excel file
51
  """
52
  # Load the Excel file using pandas
53
  try:
54
  # Read the Excel file
55
+ df = pd.read_excel(file_name, sheet_name=None) # sheet_name=None loads all sheets
56
 
57
  # Convert each sheet to a dictionary of rows
58
  json_output = {}
 
68
 
69
 
70
  @tool
71
+ def transcribe_audio(file_name: str) -> str:
72
  """Transcribe the audio file into text.
73
 
74
  Args:
75
+ file_name: name of audio file
76
  """
77
  config = aai.TranscriptionConfig(speech_model=aai.SpeechModel.best)
78
+ transcript = aai.Transcriber(config=config).transcribe(file_name)
79
  if transcript.status == "error":
80
  raise RuntimeError(f"Transcription failed: {transcript.error}")
81
  return f"Here is the transcript: {transcript.text}"
 
92
  f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
93
  for doc in search_docs
94
  ])
95
+ print(formatted_search_docs)
96
  return {"wiki_results": formatted_search_docs}
97
 
98
  # @tool
 
123
 
124
  tools = [
125
  wiki_search,
126
+ tavily_search_tool,
127
+ tavily_extract_tool,
128
  repl_tool,
129
  read_excel_file,
130
  transcribe_audio
 
169
 
170
  if __name__ == "__main__":
171
  question = "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?"
172
+ # question = "Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order."
173
+ # question = "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?"
174
+ # question = "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations."
175
  question = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
176
  # getmessages = [HumanMessage(content=question)]
177
  # messages = graph.invoke({"messages": messages})
app.py CHANGED
@@ -77,7 +77,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
77
  answers_payload = []
78
  print(f"Running agent on {len(questions_data)} questions...")
79
  for item in questions_data:
80
- time.sleep(5)
81
  task_id = item.get("task_id")
82
  question_text = item.get("question")
83
  if not task_id or question_text is None:
 
77
  answers_payload = []
78
  print(f"Running agent on {len(questions_data)} questions...")
79
  for item in questions_data:
80
+ time.sleep(10)
81
  task_id = item.get("task_id")
82
  question_text = item.get("question")
83
  if not task_id or question_text is None: