Kackle commited on
Commit
b935197
·
verified ·
1 Parent(s): a07e1a5

Update gemini_agent.py

Browse files
Files changed (1) hide show
  1. gemini_agent.py +7 -32
gemini_agent.py CHANGED
@@ -5,10 +5,9 @@ from excel_parser import ExcelParser
5
  import re
6
  import time
7
  import asyncio
8
- from google.generativeai.types import HarmCategory, HarmBlockThreshold
9
  # Add LangChain tools for Wikipedia and DuckDuckGo
10
- from langchain_community.tools import DuckDuckGoSearchRun, WikipediaQueryRun
11
- from langchain_community.utilities import WikipediaAPIWrapper
12
 
13
  load_dotenv()
14
 
@@ -20,7 +19,7 @@ class GeminiAgent:
20
  api_key = os.getenv('GOOGLE_API_KEY')
21
  genai.configure(api_key=api_key)
22
 
23
- self.model = genai.GenerativeModel('gemini-2.5-pro')
24
  self.last_request_time = 0
25
  self.min_request_interval = 6.0 # 6 seconds between requests (10 per minute limit)
26
 
@@ -78,13 +77,7 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
78
  generation_config=genai.types.GenerationConfig(
79
  max_output_tokens=50,
80
  temperature=0.0
81
- ),
82
- safety_settings={
83
- HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
84
- HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
85
- HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
86
- HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
87
- }
88
  )
89
  answer = response.text.strip()
90
 
@@ -152,13 +145,7 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
152
  generation_config=genai.types.GenerationConfig(
153
  max_output_tokens=150,
154
  temperature=0.0
155
- ),
156
- safety_settings={
157
- HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
158
- HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
159
- HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
160
- HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
161
- }
162
  )
163
  answer = response.text.strip()
164
 
@@ -251,13 +238,7 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
251
  generation_config=genai.types.GenerationConfig(
252
  max_output_tokens=100,
253
  temperature=0.0
254
- ),
255
- safety_settings={
256
- HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
257
- HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
258
- HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
259
- HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
260
- }
261
  )
262
  answer = response.text.strip()
263
 
@@ -322,13 +303,7 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
322
  generation_config=genai.types.GenerationConfig(
323
  max_output_tokens=100,
324
  temperature=0.0
325
- ),
326
- safety_settings={
327
- HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
328
- HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
329
- HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
330
- HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
331
- }
332
  )
333
  answer = response.text.strip()
334
 
 
5
  import re
6
  import time
7
  import asyncio
 
8
  # Add LangChain tools for Wikipedia and DuckDuckGo
9
+ from langchain.tools import DuckDuckGoSearchRun, WikipediaQueryRun
10
+ from langchain.utilities import WikipediaAPIWrapper
11
 
12
  load_dotenv()
13
 
 
19
  api_key = os.getenv('GOOGLE_API_KEY')
20
  genai.configure(api_key=api_key)
21
 
22
+ self.model = genai.GenerativeModel('gemini-2.0-flash-exp')
23
  self.last_request_time = 0
24
  self.min_request_interval = 6.0 # 6 seconds between requests (10 per minute limit)
25
 
 
77
  generation_config=genai.types.GenerationConfig(
78
  max_output_tokens=50,
79
  temperature=0.0
80
+ )
 
 
 
 
 
 
81
  )
82
  answer = response.text.strip()
83
 
 
145
  generation_config=genai.types.GenerationConfig(
146
  max_output_tokens=150,
147
  temperature=0.0
148
+ )
 
 
 
 
 
 
149
  )
150
  answer = response.text.strip()
151
 
 
238
  generation_config=genai.types.GenerationConfig(
239
  max_output_tokens=100,
240
  temperature=0.0
241
+ )
 
 
 
 
 
 
242
  )
243
  answer = response.text.strip()
244
 
 
303
  generation_config=genai.types.GenerationConfig(
304
  max_output_tokens=100,
305
  temperature=0.0
306
+ )
 
 
 
 
 
 
307
  )
308
  answer = response.text.strip()
309