Spaces:
Sleeping
Sleeping
commit
Browse files8 unmodified lines910111213141531 unmodified lines47484950515253547 unmodified lines6263646265666768696768707172737475767778798081828384858687887071727374757689909192939495969798991 unmodified line101102103871041051061078 unmodified lines
from langchain_openai import ChatOpenAIfrom langchain_core.messages import HumanMessagefrom langchain_community.tools import DuckDuckGoSearchRun
# (Keep Constants as is)# --- Constants ---31 unmodified lines# -------------------------------# Tools & LLM# -------------------------------# Search tool (무료)search_tool = DuckDuckGoSearchRun()
# LLM (OpenAI – 이미 네 환경에서 동작 확인됨)llm = ChatOpenAI(7 unmodified lines# -------------------------------class BasicAgent: def __init__(self): print("GAIA LLM-only Agent initialized.") print("Search-based GAIA Agent initialized.")
def __call__(self, question: str) -> str: print(f"Question: {question[:80]}...")
prompt = f"""You are solving a GAIA benchmark question. queries = [ question, f"{question} wikipedia", f"{question} site:wikipedia.org", f"{question} fact", ]
snippets = [] for q in queries: try: r = search_tool.run(q) if r: snippets.append(r) time.sleep(0.5) # rate-limit 회피 except Exception as e: print("Search error:", e)
search_result = "\n\n".join(snippets)
Rules:- Answer with ONLY the final answer.- No explanation.- No formatting.- No extra text.- If the answer is a number, output ONLY the number.- If the answer is Yes/No, output ONLY Yes or No. prompt = f"""{SYSTEM_PROMPT}
Question:{question}
Search Results:{search_result}""".strip()
response = llm.invoke([HumanMessage(content=prompt)])1 unmodified line
print(f"Answer: {answer}") return answer
def run_and_submit_all( profile: gr.OAuthProfile | None): """ Fetches all questions, runs the BasicAgent on them, submits all answers,app.py+28-11