nikhmr1235 commited on
Commit
590f46b
·
verified ·
1 Parent(s): 0a78f01

add audio transcribe support

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -23,7 +23,7 @@ from langchain_openai import ChatOpenAI
23
  from openai import OpenAI
24
 
25
  # tools imported from helper.py
26
- from helper import repl_tool, get_travily_api_search_tool,web_downloader_limited_tool
27
 
28
 
29
 
@@ -149,7 +149,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
149
  print(f"Using Tavily API key: {tavily_api_key[:4]}... (truncated for security)")
150
 
151
  travily_api_search_tool = get_travily_api_search_tool(tavily_api_key)
152
- tools = [travily_api_search_tool, repl_tool, web_downloader_limited_tool]
153
 
154
  # Pull a predefined prompt from LangChain Hub
155
  # "hwchase17/react-chat" is a prompt template designed for ReAct-style conversational agents.
@@ -170,9 +170,13 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
170
  Action Input: [input_for_the_tool]
171
  Observation: [result_from_the_tool]
172
 
173
- NOTE: If the input contains the exact phrase "Attachment '{{file_name}}' available at: {{attachment_url}}" (where '{{file_name}}' and '{{attachment_url}}' are placeholders for actual values), then you MUST use the 'web_downloader_limited' tool. Otherwise, you should use the 'tavily_search' tool.
 
 
 
174
 
175
- If you have sufficient information and can provide a concise response, or if no tool is needed, you MUST use this precise format:
 
176
 
177
  Thought: I have enough information, or no tool is needed.
178
  Final Answer: [your concise response here]
@@ -278,12 +282,13 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
278
  full_question_for_agent = question_text
279
  if file_name:
280
  attachment_url = f"https://agents-course-unit4-scoring.hf.space/files/{task_id}"
281
- full_question_for_agent += f"\n\nAttachment '{file_name}' available at: {attachment_url}"
282
- '''
283
- if task_id != "f918266a-b3e0-4914-865d-4faa564f1aef":
 
284
  print("NFLUSH Skip tasks that are not the specific one we want to run", flush=True)
285
  continue # Skip tasks that are not the specific one we want to run
286
- '''
287
  try:
288
  time.sleep(5) # Add a 5 sec delay before running the agent
289
  submitted_answer = agent(full_question_for_agent)
 
23
  from openai import OpenAI
24
 
25
  # tools imported from helper.py
26
+ from helper import repl_tool, get_travily_api_search_tool,text_downloader_limited_tool,audio_transcriber_tool
27
 
28
 
29
 
 
149
  print(f"Using Tavily API key: {tavily_api_key[:4]}... (truncated for security)")
150
 
151
  travily_api_search_tool = get_travily_api_search_tool(tavily_api_key)
152
+ tools = [travily_api_search_tool, repl_tool, text_downloader_limited_tool,audio_transcriber_tool]
153
 
154
  # Pull a predefined prompt from LangChain Hub
155
  # "hwchase17/react-chat" is a prompt template designed for ReAct-style conversational agents.
 
170
  Action Input: [input_for_the_tool]
171
  Observation: [result_from_the_tool]
172
 
173
+ NOTE: If the input contains the exact phrase "Attachment '{{file_name}}' available at: {{attachment_url}}" (where '{{file_name}}' and '{{attachment_url}}' are placeholders for actual values), then you may use the 'text_downloader_limited_tool' tool if needed. Otherwise, you should use the 'tavily_search' tool.
174
+ based on the input {context}, if the file type is text, you MUST use text_downloader_limited_tool
175
+ DO NOT use text_downloader_limited_tool for audio,video or image files
176
+ for example: if task_id,cca530fc-7888-43b2-b130-b30968d8aa44, attachment URL will be https://agents-course-unit4-scoring.hf.space/files/cca530fc-7888-43b2-b130-b30968d8aa44
177
 
178
+
179
+ If you have sufficient information and can provide a CONCISE response, or if no tool is needed, you MUST use this precise format:
180
 
181
  Thought: I have enough information, or no tool is needed.
182
  Final Answer: [your concise response here]
 
282
  full_question_for_agent = question_text
283
  if file_name:
284
  attachment_url = f"https://agents-course-unit4-scoring.hf.space/files/{task_id}"
285
+ full_question_for_agent += f"\n\nAttachment '{file_name}' available at EXACT URL: {attachment_url}"
286
+ print(f"Running agent on task {task_id}: {full_question_for_agent}",flush=True)
287
+
288
+ if task_id != "1f975693-876d-457b-a649-393859e79bf3":
289
  print("NFLUSH Skip tasks that are not the specific one we want to run", flush=True)
290
  continue # Skip tasks that are not the specific one we want to run
291
+
292
  try:
293
  time.sleep(5) # Add a 5 sec delay before running the agent
294
  submitted_answer = agent(full_question_for_agent)