Spaces:
Running on Zero
Running on Zero
| import os | |
| from dotenv import load_dotenv | |
| from langchain_core.messages import SystemMessage | |
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| from langgraph.prebuilt import create_react_agent | |
| from tools import all_tools | |
| # Load the API keys from your .env file | |
| load_dotenv() | |
| # Verify the Gemini API key is mapped correctly | |
| if "GEMINI_API_KEY" not in os.environ: | |
| print("Warning: Please set your GEMINI_API_KEY environment variable.") | |
| # Initialize the Gemini LLM engine | |
| # temperature=0 ensures strict, objective tool choices | |
| # Initialize a stable free-tier model with broader token windows | |
| llm = ChatGoogleGenerativeAI(model="gemini-3.1-flash-lite", temperature=0) | |
| # GAIA exact-match rules to block conversational fluff | |
| GAIA_SYSTEM_PROMPT = ( | |
| "You are an objective, precise AI assistant evaluating GAIA tasks.\n" | |
| "Your final response must contain ONLY the raw, objective final answer.\n" | |
| "Strict Rules:\n" | |
| "- Do NOT include conversational text (e.g., 'The answer is...').\n" | |
| "- Do NOT use formatting prefixes like 'Answer:' or 'FINAL ANSWER:'.\n" | |
| "- Output only the exact words, numbers, or list requested, and absolutely nothing else." | |
| ) | |
| # Compile the LangGraph ReAct agent workflow using Gemini | |
| agent_executor = create_react_agent( | |
| model=llm, | |
| tools=all_tools, | |
| prompt=GAIA_SYSTEM_PROMPT | |
| ) |