prasoonmhwr commited on
Commit
3f9898a
·
1 Parent(s): 525e313

updated code

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -21,12 +21,12 @@ class BasicAgent:
21
 
22
  # Initialize Google Generative AI client
23
  # It's recommended to set GOOGLE_API_KEY as an environment variable
24
- gemini_api_key = "AIzaSyAwgCoL6IjGotj0y27Rirb5GvtVLTDF8jc"
25
- if not gemini_api_key:
26
  print("Warning: GOOGLE_API_KEY not found. Gemini API calls might fail.")
27
  print("Please set the GOOGLE_API_KEY environment variable.")
28
 
29
- genai.configure(api_key=gemini_api_key)
30
  self.gemini_client = genai
31
  self.gemini_model = "gemini-2.5-flash" # Specify Gemini Flash model
32
 
@@ -55,7 +55,7 @@ class BasicAgent:
55
  """Call LLM with the given prompt - supports multiple providers"""
56
  try:
57
  # Option 1: Google Gemini Flash
58
- if os.getenv("GOOGLE_API_KEY"):
59
  model = self.gemini_client.GenerativeModel(self.gemini_model)
60
  response = model.generate_content(
61
  prompt,
@@ -164,7 +164,7 @@ class BasicAgent:
164
 
165
  elif tool_name == 'web_search':
166
  query = match.group(1).strip('"\'')
167
- result = search_tool(query)
168
  enhanced_response = enhanced_response.replace(match.group(0), f"search result: {result}")
169
 
170
  except Exception as e:
 
21
 
22
  # Initialize Google Generative AI client
23
  # It's recommended to set GOOGLE_API_KEY as an environment variable
24
+ self.gemini_api_key = "AIzaSyAwgCoL6IjGotj0y27Rirb5GvtVLTDF8jc"
25
+ if not self.gemini_api_key:
26
  print("Warning: GOOGLE_API_KEY not found. Gemini API calls might fail.")
27
  print("Please set the GOOGLE_API_KEY environment variable.")
28
 
29
+ genai.configure(api_key=self.gemini_api_key)
30
  self.gemini_client = genai
31
  self.gemini_model = "gemini-2.5-flash" # Specify Gemini Flash model
32
 
 
55
  """Call LLM with the given prompt - supports multiple providers"""
56
  try:
57
  # Option 1: Google Gemini Flash
58
+ if self.gemini_api_key:
59
  model = self.gemini_client.GenerativeModel(self.gemini_model)
60
  response = model.generate_content(
61
  prompt,
 
164
 
165
  elif tool_name == 'web_search':
166
  query = match.group(1).strip('"\'')
167
+ result = search_tool.invoke(query)
168
  enhanced_response = enhanced_response.replace(match.group(0), f"search result: {result}")
169
 
170
  except Exception as e: