Spaces:
Sleeping
Sleeping
Update gemini_agent.py
Browse files- gemini_agent.py +27 -6
gemini_agent.py
CHANGED
|
@@ -5,9 +5,10 @@ from excel_parser import ExcelParser
|
|
| 5 |
import re
|
| 6 |
import time
|
| 7 |
import asyncio
|
|
|
|
| 8 |
# Add LangChain tools for Wikipedia and DuckDuckGo
|
| 9 |
-
from
|
| 10 |
-
from
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
|
@@ -78,7 +79,12 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 78 |
max_output_tokens=50,
|
| 79 |
temperature=0.0
|
| 80 |
),
|
| 81 |
-
safety_settings={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
)
|
| 83 |
answer = response.text.strip()
|
| 84 |
|
|
@@ -147,7 +153,12 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 147 |
max_output_tokens=150,
|
| 148 |
temperature=0.0
|
| 149 |
),
|
| 150 |
-
safety_settings={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
)
|
| 152 |
answer = response.text.strip()
|
| 153 |
|
|
@@ -241,7 +252,12 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 241 |
max_output_tokens=100,
|
| 242 |
temperature=0.0
|
| 243 |
),
|
| 244 |
-
safety_settings={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
)
|
| 246 |
answer = response.text.strip()
|
| 247 |
|
|
@@ -307,7 +323,12 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 307 |
max_output_tokens=100,
|
| 308 |
temperature=0.0
|
| 309 |
),
|
| 310 |
-
safety_settings={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
)
|
| 312 |
answer = response.text.strip()
|
| 313 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|