D3MI4N commited on
Commit
94958b6
Β·
1 Parent(s): 9d3db05

go back to last working version, but using gpt-40-mini

Browse files
Files changed (1) hide show
  1. gaia_graph.py +2 -14
gaia_graph.py CHANGED
@@ -11,9 +11,6 @@ from langchain.agents import initialize_agent, AgentType
11
  from langchain_openai import ChatOpenAI
12
  from langgraph.graph import StateGraph, END
13
 
14
- import openai # Import openai to catch RateLimitError
15
- from tenacity import retry, wait_exponential, stop_after_attempt, retry_if_exception_type
16
-
17
  # ─── Load Environment Variables ──────────────────────────────────────────────
18
  load_dotenv()
19
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
@@ -78,7 +75,7 @@ search_tool = Tool(
78
  # ─── Create LLM Agent ────────────────────────────────────────────────────────
79
  llm = ChatOpenAI(
80
  temperature=0.0,
81
- model="gpt-4o",
82
  openai_api_key=OPENAI_API_KEY
83
  )
84
 
@@ -105,18 +102,9 @@ class GaiaState(TypedDict):
105
  question: str
106
  answer: str
107
 
108
- # ─── Retry on Rate Limit Error ───────────────────────────────────────────────
109
- @retry(
110
- wait=wait_exponential(multiplier=1, min=1, max=10),
111
- stop=stop_after_attempt(5),
112
- retry=retry_if_exception_type(openai.error.RateLimitError)
113
- )
114
- def run_agent_with_retry(question: str) -> str:
115
- return agent_executor.run(question)
116
-
117
  # ─── Define Node Function ────────────────────────────────────────────────────
118
  def agent_node(state: GaiaState) -> GaiaState:
119
- raw = run_agent_with_retry(state["question"])
120
  return {"question": state["question"], "answer": clean_answer(raw)}
121
 
122
  # ─── Build LangGraph ─────────────────────────────────────────────────────────
 
11
  from langchain_openai import ChatOpenAI
12
  from langgraph.graph import StateGraph, END
13
 
 
 
 
14
  # ─── Load Environment Variables ──────────────────────────────────────────────
15
  load_dotenv()
16
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
 
75
  # ─── Create LLM Agent ────────────────────────────────────────────────────────
76
  llm = ChatOpenAI(
77
  temperature=0.0,
78
+ model="gpt-4o-mini",
79
  openai_api_key=OPENAI_API_KEY
80
  )
81
 
 
102
  question: str
103
  answer: str
104
 
 
 
 
 
 
 
 
 
 
105
  # ─── Define Node Function ────────────────────────────────────────────────────
106
  def agent_node(state: GaiaState) -> GaiaState:
107
+ raw = agent_executor.run(state["question"])
108
  return {"question": state["question"], "answer": clean_answer(raw)}
109
 
110
  # ─── Build LangGraph ─────────────────────────────────────────────────────────