likki1715 commited on
Commit
bda8117
·
verified ·
1 Parent(s): 2452c97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -94,9 +94,9 @@ def web_fetch(url: str) -> str:
94
  text = soup.get_text(separator="\n", strip=True)
95
  # Collapse excessive newlines
96
  text = re.sub(r'\n{3,}', '\n\n', text)
97
- return text[:4000]
98
  except ImportError:
99
- return response.text[:4000]
100
  except Exception as e:
101
  return f"Fetch error: {e}"
102
 
@@ -120,7 +120,7 @@ def wikipedia_search(query: str) -> str:
120
  pages = summary_data.get("query", {}).get("pages", {})
121
  for page_id, page in pages.items():
122
  extract = page.get("extract", "No content available.")
123
- return f"Wikipedia: {title}\n\n{extract[:4000]}"
124
  return "No content found."
125
  except Exception as e:
126
  return f"Wikipedia error: {e}"
@@ -226,7 +226,7 @@ CRITICAL RULES:
226
  conversation = f"{system}\n\nQuestion: {question}{file_alert}"
227
 
228
  for iteration in range(10):
229
- time.sleep(5) # Increased rate limit safety
230
 
231
  response = self.call_llm(conversation)
232
  print(f" LLM [{iteration}]: \n{response[:300]}...\n")
@@ -325,7 +325,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
325
  print(f"Error on task {task_id}: {e}")
326
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"ERROR: {e}"})
327
 
328
- time.sleep(8) # Increased safety pause between questions
329
 
330
  if not answers_payload:
331
  return "Agent did not produce any answers.", pd.DataFrame(results_log)
 
94
  text = soup.get_text(separator="\n", strip=True)
95
  # Collapse excessive newlines
96
  text = re.sub(r'\n{3,}', '\n\n', text)
97
+ return text[:2000]
98
  except ImportError:
99
+ return response.text[:2000]
100
  except Exception as e:
101
  return f"Fetch error: {e}"
102
 
 
120
  pages = summary_data.get("query", {}).get("pages", {})
121
  for page_id, page in pages.items():
122
  extract = page.get("extract", "No content available.")
123
+ return f"Wikipedia: {title}\n\n{extract[:2000]}"
124
  return "No content found."
125
  except Exception as e:
126
  return f"Wikipedia error: {e}"
 
226
  conversation = f"{system}\n\nQuestion: {question}{file_alert}"
227
 
228
  for iteration in range(10):
229
+ time.sleep(8) # Increased rate limit safety
230
 
231
  response = self.call_llm(conversation)
232
  print(f" LLM [{iteration}]: \n{response[:300]}...\n")
 
325
  print(f"Error on task {task_id}: {e}")
326
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"ERROR: {e}"})
327
 
328
+ time.sleep(15) # Increased safety pause between questions
329
 
330
  if not answers_payload:
331
  return "Agent did not produce any answers.", pd.DataFrame(results_log)