Bandook01 commited on
Commit
28f9e29
·
1 Parent(s): 0a130e3

exception handling

Browse files
Files changed (1) hide show
  1. app.py +16 -13
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
- gemini_api_key = os.getenv("GEMINI_API_KEY")
55
- if not gemini_api_key:
56
- raise ValueError("GEMINI_API_KEY not set in environment variables.")
57
- llm = GoogleGenAI(
58
- model="gemini-2.0-flash",
59
- api_key=gemini_api_key,
60
- )
61
- agent = FunctionAgent(
62
- tools=[ReverseTextTool,RunPythonFileTool,download_server,wiki_tool,YoutubeTranscript],
63
- llm=llm,
64
- system_prompt=SYSTEM_PROMPT,
65
- )
66
- print("BasicAgent initialized.")
 
 
 
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."""