app.py
CHANGED
@@ -24,6 +24,16 @@ def merge_dicts(old: Dict, new: Dict) -> Dict:
|
|
24 |
"""Merge two dictionaries, with *new* values taking precedence."""
|
25 |
return {**old, **new}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# -------------------------
|
28 |
# Environment & constants
|
29 |
# -------------------------
|
|
|
24 |
"""Merge two dictionaries, with *new* values taking precedence."""
|
25 |
return {**old, **new}
|
26 |
|
27 |
+
def tighten(q: str) -> str:
|
28 |
+
"""
|
29 |
+
Strip long GAIA questions down to quoted phrases and capitalised words.
|
30 |
+
Falls back to the original text if we strip too much.
|
31 |
+
"""
|
32 |
+
quoted = re.findall(r'"([^"]+)"', q)
|
33 |
+
caps = re.findall(r'\b([A-Z0-9][\w-]{2,})', q)
|
34 |
+
short = " ".join(quoted + caps)
|
35 |
+
return short or q
|
36 |
+
|
37 |
# -------------------------
|
38 |
# Environment & constants
|
39 |
# -------------------------
|
tools.py
CHANGED
@@ -13,7 +13,7 @@ def tighten(q: str) -> str:
|
|
13 |
def _raw_search(query: str, max_results: int = 5) -> List[str]:
|
14 |
"""Internal function that performs the actual DuckDuckGo search."""
|
15 |
with DDGS() as ddgs:
|
16 |
-
raw = list(ddgs.text(
|
17 |
out = []
|
18 |
for r in raw:
|
19 |
try:
|
|
|
13 |
def _raw_search(query: str, max_results: int = 5) -> List[str]:
|
14 |
"""Internal function that performs the actual DuckDuckGo search."""
|
15 |
with DDGS() as ddgs:
|
16 |
+
raw = list(ddgs.text(query, max_results=max_results))
|
17 |
out = []
|
18 |
for r in raw:
|
19 |
try:
|