Update app.py
Browse filesmoved get_file function definition to outside of agent class
app.py
CHANGED
|
@@ -22,6 +22,21 @@ GEMINI_API_KEY = os.getenv("Gemini_API_key")
|
|
| 22 |
# Agent capabilities required: Search the web, listen to audio recordings, watch YouTube videos (process the footage, not the transcript), work with Excel spreadsheets
|
| 23 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
class BasicAgent:
|
| 26 |
def __init__(self):
|
| 27 |
self.llm_model = LiteLLMModel(
|
|
@@ -31,7 +46,8 @@ class BasicAgent:
|
|
| 31 |
)
|
| 32 |
# self.google_search_tool = Tool(google_search = GoogleSearch())
|
| 33 |
self.google_search_tool = GoogleSearchTool()
|
| 34 |
-
self.
|
|
|
|
| 35 |
# # Define Google API client with GoogleSearch tool
|
| 36 |
# self.client = genai.Client(api_key=GEMINI_API_KEY)
|
| 37 |
|
|
@@ -57,21 +73,6 @@ class BasicAgent:
|
|
| 57 |
# )
|
| 58 |
# return answer.text
|
| 59 |
|
| 60 |
-
@tool
|
| 61 |
-
@staticmethod
|
| 62 |
-
def get_file(task_id: str) -> IO:
|
| 63 |
-
'''
|
| 64 |
-
Downloads the file associated with the given task_id, if one exists and is mapped.
|
| 65 |
-
If the question mentions an attachment, use this function.
|
| 66 |
-
Args:
|
| 67 |
-
task_id: Id of the question.
|
| 68 |
-
Returns:
|
| 69 |
-
The file associated with the question.
|
| 70 |
-
'''
|
| 71 |
-
file_request = requests.get(url=f'https://agents-course-unit4-scoring.hf.space/files/{task_id}')
|
| 72 |
-
file_request.raise_for_status()
|
| 73 |
-
|
| 74 |
-
return file_request
|
| 75 |
|
| 76 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 77 |
"""
|
|
|
|
| 22 |
# Agent capabilities required: Search the web, listen to audio recordings, watch YouTube videos (process the footage, not the transcript), work with Excel spreadsheets
|
| 23 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 24 |
|
| 25 |
+
@tool
|
| 26 |
+
def get_file(task_id: str) -> IO:
|
| 27 |
+
'''
|
| 28 |
+
Downloads the file associated with the given task_id, if one exists and is mapped.
|
| 29 |
+
If the question mentions an attachment, use this function.
|
| 30 |
+
Args:
|
| 31 |
+
task_id: Id of the question.
|
| 32 |
+
Returns:
|
| 33 |
+
The file associated with the question.
|
| 34 |
+
'''
|
| 35 |
+
file_request = requests.get(url=f'https://agents-course-unit4-scoring.hf.space/files/{task_id}')
|
| 36 |
+
file_request.raise_for_status()
|
| 37 |
+
|
| 38 |
+
return file_request
|
| 39 |
+
|
| 40 |
class BasicAgent:
|
| 41 |
def __init__(self):
|
| 42 |
self.llm_model = LiteLLMModel(
|
|
|
|
| 46 |
)
|
| 47 |
# self.google_search_tool = Tool(google_search = GoogleSearch())
|
| 48 |
self.google_search_tool = GoogleSearchTool()
|
| 49 |
+
self.get_file_tool = get_file
|
| 50 |
+
self.agent = CodeAgent(model = self.llm_model, tools = [self.google_search_tool, get_file_tool])
|
| 51 |
# # Define Google API client with GoogleSearch tool
|
| 52 |
# self.client = genai.Client(api_key=GEMINI_API_KEY)
|
| 53 |
|
|
|
|
| 73 |
# )
|
| 74 |
# return answer.text
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 78 |
"""
|