Spaces:
Sleeping
Sleeping
File size: 1,374 Bytes
00b591a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 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
) |