Spaces:
Sleeping
Sleeping
commit
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ def clean_answer(text: str) -> str:
|
|
| 45 |
|
| 46 |
if s.lower() in ["yes", "no"]:
|
| 47 |
s = s.capitalize()
|
| 48 |
-
|
| 49 |
return s
|
| 50 |
|
| 51 |
def classify_question(q: str) -> str:
|
|
@@ -89,30 +89,37 @@ class BasicAgent:
|
|
| 89 |
print(f"Question: {question[:80]}...")
|
| 90 |
|
| 91 |
qtype = classify_question(question)
|
| 92 |
-
rule = RULES[qtype]
|
| 93 |
|
| 94 |
-
# ๊ฒ์
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
try:
|
| 101 |
-
search_result = search_tool.run(
|
| 102 |
-
if not search_result:
|
| 103 |
-
raise RuntimeError("empty search")
|
| 104 |
except Exception:
|
| 105 |
-
|
| 106 |
-
search_result = search_tool.run(question)
|
| 107 |
-
except Exception:
|
| 108 |
-
search_result = ""
|
| 109 |
|
| 110 |
prompt = f"""
|
| 111 |
{SYSTEM_PROMPT}
|
| 112 |
|
| 113 |
-
Additional Rules:
|
| 114 |
-
- {rule}
|
| 115 |
-
|
| 116 |
Question:
|
| 117 |
{question}
|
| 118 |
|
|
@@ -123,7 +130,7 @@ class BasicAgent:
|
|
| 123 |
response = llm.invoke([HumanMessage(content=prompt)])
|
| 124 |
answer = clean_answer(response.content)
|
| 125 |
|
| 126 |
-
print(f"Answer: {answer}")
|
| 127 |
return answer
|
| 128 |
|
| 129 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
|
| 45 |
|
| 46 |
if s.lower() in ["yes", "no"]:
|
| 47 |
s = s.capitalize()
|
| 48 |
+
|
| 49 |
return s
|
| 50 |
|
| 51 |
def classify_question(q: str) -> str:
|
|
|
|
| 89 |
print(f"Question: {question[:80]}...")
|
| 90 |
|
| 91 |
qtype = classify_question(question)
|
|
|
|
| 92 |
|
| 93 |
+
# ๐น 1๋จ๊ณ: ๊ฒ์ ์์ด ๋จผ์ ๋ต ์๋
|
| 94 |
+
base_prompt = f"""
|
| 95 |
+
You are solving a GAIA benchmark question.
|
| 96 |
+
|
| 97 |
+
Rules:
|
| 98 |
+
- Answer with ONLY the final answer
|
| 99 |
+
- No explanation
|
| 100 |
+
- No extra text
|
| 101 |
|
| 102 |
+
Question:
|
| 103 |
+
{question}
|
| 104 |
+
""".strip()
|
| 105 |
+
|
| 106 |
+
base_response = llm.invoke([HumanMessage(content=base_prompt)])
|
| 107 |
+
base_answer = clean_answer(base_response.content)
|
| 108 |
+
|
| 109 |
+
# ๐น ์ซ์/์ฐ๋/YesNo๊ฐ ๋ช
ํํ๋ฉด ๋ฐ๋ก ๋ฐํ
|
| 110 |
+
if qtype in ["number", "date", "yesno"] and base_answer:
|
| 111 |
+
print(f"Answer (no search): {base_answer}")
|
| 112 |
+
return base_answer
|
| 113 |
+
|
| 114 |
+
# ๐น 2๋จ๊ณ: ๊ทธ๋๋ ์ ๋งคํ๋ฉด ๊ฒ์ ์ฌ์ฉ
|
| 115 |
try:
|
| 116 |
+
search_result = search_tool.run(question)
|
|
|
|
|
|
|
| 117 |
except Exception:
|
| 118 |
+
search_result = ""
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
prompt = f"""
|
| 121 |
{SYSTEM_PROMPT}
|
| 122 |
|
|
|
|
|
|
|
|
|
|
| 123 |
Question:
|
| 124 |
{question}
|
| 125 |
|
|
|
|
| 130 |
response = llm.invoke([HumanMessage(content=prompt)])
|
| 131 |
answer = clean_answer(response.content)
|
| 132 |
|
| 133 |
+
print(f"Answer (with search): {answer}")
|
| 134 |
return answer
|
| 135 |
|
| 136 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|