refactor: Remove explicit `google_api_key` assignment for Gemini model, relying on automatic environment variable pickup.
Browse files- __pycache__/agent.cpython-312.pyc +0 -0
- agent.py +11 -13
__pycache__/agent.cpython-312.pyc
ADDED
|
Binary file (22 kB). View file
|
|
|
agent.py
CHANGED
|
@@ -66,7 +66,7 @@ openrouter_model = ChatOpenAI(
|
|
| 66 |
# Google AI Studio Fallback Model (Gemini)
|
| 67 |
gemini_model = ChatGoogleGenerativeAI(
|
| 68 |
model="gemini-1.5-pro",
|
| 69 |
-
google_api_key
|
| 70 |
temperature=0,
|
| 71 |
)
|
| 72 |
|
|
@@ -392,24 +392,22 @@ def answer_message(state: AgentState) -> AgentState:
|
|
| 392 |
|
| 393 |
TODAY'S EXACT DATE is {current_date}. Keep this in mind for all time-sensitive queries.
|
| 394 |
|
| 395 |
-
CRITICAL RULES FOR
|
| 396 |
-
1. If
|
| 397 |
-
2.
|
| 398 |
-
3.
|
| 399 |
-
4.
|
| 400 |
-
5.
|
| 401 |
-
6. Cross-reference facts if they seem ambiguous.
|
| 402 |
|
| 403 |
-
|
| 404 |
-
|
|
|
|
|
|
|
| 405 |
|
| 406 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 407 |
If you are asked for a number, don't use comma to write your number, and don't use units such as $ or percent sign unless specified otherwise.
|
| 408 |
If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
|
| 409 |
If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
|
| 410 |
-
|
| 411 |
-
Example question: How many hours are there in a day?
|
| 412 |
-
Response: 24
|
| 413 |
""")]
|
| 414 |
messages = prompt + messages
|
| 415 |
|
|
|
|
| 66 |
# Google AI Studio Fallback Model (Gemini)
|
| 67 |
gemini_model = ChatGoogleGenerativeAI(
|
| 68 |
model="gemini-1.5-pro",
|
| 69 |
+
# google_api_key is automatically picked up from GOOGLE_API_KEY environment variable
|
| 70 |
temperature=0,
|
| 71 |
)
|
| 72 |
|
|
|
|
| 392 |
|
| 393 |
TODAY'S EXACT DATE is {current_date}. Keep this in mind for all time-sensitive queries.
|
| 394 |
|
| 395 |
+
CRITICAL RULES FOR FILES & TOOLS:
|
| 396 |
+
1. If a message contains a path like `[Attached File Local Path: ...]` followed by an image (.png, .jpg, .jpeg), video, or audio file, YOU MUST USE THE CORRESPONDING TOOL (analyze_image, analyze_video, analyze_audio).
|
| 397 |
+
2. YOU ARE NOT BLIND. NEVER say "I cannot see images" or "I don't have access to files". Use your tools to see and hear for you!
|
| 398 |
+
3. If you see a file path, invoke the tool IMMEDIATELY in your first ReAct step.
|
| 399 |
+
4. For text/data files, use `read_document` or `run_python_script` (especially for .xlsx or .pdf).
|
| 400 |
+
5. Be thorough. If one tool doesn't give enough info, use another (e.g., search the web for context).
|
|
|
|
| 401 |
|
| 402 |
+
Example of Tool Trigger:
|
| 403 |
+
User: "What is in this image? [Attached File Local Path: /path/to/image.png]"
|
| 404 |
+
Your Thought: "I need to see the image to answer. I will use the analyze_image tool."
|
| 405 |
+
Your Action: Call `analyze_image(image_path='/path/to/image.png', question='What is in this image?')`
|
| 406 |
|
| 407 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 408 |
If you are asked for a number, don't use comma to write your number, and don't use units such as $ or percent sign unless specified otherwise.
|
| 409 |
If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
|
| 410 |
If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
|
|
|
|
|
|
|
|
|
|
| 411 |
""")]
|
| 412 |
messages = prompt + messages
|
| 413 |
|