naman1102 commited on
Commit
0f38f21
·
1 Parent(s): 1805291

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -71,7 +71,7 @@ class BasicAgent:
71
  # ---- Low‑level LLM call
72
  def _call_llm(self, prompt: str, max_tokens: int = 256) -> str:
73
  resp = self.llm.chat.completions.create(
74
- model="gpt-3.5-turbo",
75
  messages=[
76
  {"role": "system", "content": "You are a careful reasoning assistant."},
77
  {"role": "user", "content": prompt},
@@ -135,8 +135,16 @@ class BasicAgent:
135
  return text.strip()
136
 
137
  def _generate_answer(self, state: AgentState) -> AgentState:
138
- # Get the last search results
139
- search_block = "\n".join(state["history"][-1]["results"]) # last search step
 
 
 
 
 
 
 
 
140
 
141
  prompt = f"""
142
  You are an expert fact-extractor. Using ONLY the text below, answer the question.
 
71
  # ---- Low‑level LLM call
72
  def _call_llm(self, prompt: str, max_tokens: int = 256) -> str:
73
  resp = self.llm.chat.completions.create(
74
+ model="gpt-4o-mini",
75
  messages=[
76
  {"role": "system", "content": "You are a careful reasoning assistant."},
77
  {"role": "user", "content": prompt},
 
135
  return text.strip()
136
 
137
  def _generate_answer(self, state: AgentState) -> AgentState:
138
+ # Get the last search results with error handling
139
+ search_block = "No search results available."
140
+ try:
141
+ # Find the last search step in history
142
+ search_steps = [item for item in state["history"] if item.get("step") == "search"]
143
+ if search_steps and "results" in search_steps[-1]:
144
+ search_block = "\n".join(search_steps[-1]["results"])
145
+ except Exception as e:
146
+ print(f"Error accessing search results: {e}")
147
+ search_block = "Error retrieving search results."
148
 
149
  prompt = f"""
150
  You are an expert fact-extractor. Using ONLY the text below, answer the question.