Spaces:
Sleeping
Sleeping
exception handling
Browse files
app.py
CHANGED
|
@@ -51,19 +51,22 @@ Tool Use Guidelines:
|
|
| 51 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 52 |
class BasicAgent:
|
| 53 |
def __init__(self):
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
def __call__(self, input_text: str):
|
| 69 |
"""Make the agent callable directly."""
|
|
|
|
| 51 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 52 |
class BasicAgent:
|
| 53 |
def __init__(self):
|
| 54 |
+
try:
|
| 55 |
+
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 56 |
+
if not gemini_api_key:
|
| 57 |
+
raise ValueError("GEMINI_API_KEY not set in environment variables.")
|
| 58 |
+
llm = GoogleGenAI(
|
| 59 |
+
model="gemini-2.0-flash",
|
| 60 |
+
api_key=gemini_api_key,
|
| 61 |
+
)
|
| 62 |
+
self.agent = FunctionAgent(
|
| 63 |
+
tools=[ReverseTextTool,RunPythonFileTool,download_server,wiki_tool,YoutubeTranscript],
|
| 64 |
+
llm=llm,
|
| 65 |
+
system_prompt=SYSTEM_PROMPT,
|
| 66 |
+
)
|
| 67 |
+
print("BasicAgent initialized.")
|
| 68 |
+
except Exception as e:
|
| 69 |
+
print(f"Error intialising agent: {e}")
|
| 70 |
|
| 71 |
def __call__(self, input_text: str):
|
| 72 |
"""Make the agent callable directly."""
|