RCaz commited on
Commit
31dbc84
·
verified ·
1 Parent(s): 0cbbf63

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +26 -3
agent.py CHANGED
@@ -64,7 +64,7 @@ def describe_image(request:str, file_path: str) -> str:
64
  Extract and return the requested information from an image.
65
 
66
  Args:
67
- request: The information to retreive from the image.
68
  file_path (str): Path to the audio file to be transcribed. The file should
69
  be in a format compatible with the SpeechRecognition library.
70
 
@@ -107,6 +107,15 @@ def describe_image(request:str, file_path: str) -> str:
107
  )
108
 
109
  return response.output_text
 
 
 
 
 
 
 
 
 
110
 
111
  class TestAgent:
112
  def __init__(self):
@@ -149,9 +158,23 @@ class TestAgent:
149
  )
150
  # V3. add Guidance
151
  prompt_for_guidance = "\n10. Provide the answer axactly as it is asked, be concise and precise\n\nNow Begin!"
152
- self.agent.prompt_templates['system_prompt'] = self.agent.prompt_templates['system_prompt'] + prompt_for_guidance
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
- # V4. use prompt from the paper ?
155
 
156
  def __call__(self, question: str) -> str:
157
 
 
64
  Extract and return the requested information from an image.
65
 
66
  Args:
67
+ request: The information to retreive from the image. The request must be simple, short and precise.
68
  file_path (str): Path to the audio file to be transcribed. The file should
69
  be in a format compatible with the SpeechRecognition library.
70
 
 
107
  )
108
 
109
  return response.output_text
110
+
111
+
112
+ @tool
113
+ def get_transcript(file_id:str) -> str:
114
+ from youtube_transcript_api import YouTubeTranscriptApi
115
+ ytt_api = YouTubeTranscriptApi()
116
+ transcript = ytt_api.fetch(video_id)
117
+ return transcript
118
+
119
 
120
  class TestAgent:
121
  def __init__(self):
 
158
  )
159
  # V3. add Guidance
160
  prompt_for_guidance = "\n10. Provide the answer axactly as it is asked, be concise and precise\n\nNow Begin!"
161
+ #self.agent.prompt_templates['system_prompt'] = self.agent.prompt_templates['system_prompt'] + prompt_for_guidance
162
+
163
+ # V4. use prompt from the paper as guidance
164
+ prompt = """\n\n
165
+ Remember: You are a general AI assistant. I will ask you a question. Report your thoughts, and
166
+ finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
167
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated
168
+ list of numbers and/or strings.
169
+ If you are asked for a number, don’t use comma to write your number neither use units such as $ or
170
+ percent sign unless specified otherwise.
171
+ If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the
172
+ digits in plain text unless specified otherwise.
173
+ If you are asked for a comma separated list, apply the above rules depending of whether the element
174
+ to be put in the list is a number or a string.
175
+ """
176
+ self.agent.prompt_templates['system_prompt'] = self.agent.prompt_templates['system_prompt'] + prompt
177
 
 
178
 
179
  def __call__(self, question: str) -> str:
180