Spaces:
Runtime error
Runtime error
Add `extract_pattern` utility function to support regex-based string extraction in `gaia_solving_agent`
Browse files
src/gaia_solving_agent/utils.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def extract_pattern(pattern: str, text: str) -> str:
|
| 5 |
+
search = re.search(pattern, text)
|
| 6 |
+
extracted = search.group(1) if search else ""
|
| 7 |
+
return extracted
|