Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -88,6 +88,14 @@ OPENALEX_MAILTO = os.environ.get("OPENALEX_MAILTO", "rairo@sozofix.tech")
|
|
| 88 |
# 2. HELPER FUNCTIONS & AUTHENTICATION
|
| 89 |
# -----------------------------------------------------------------------------
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def verify_token(auth_header):
|
| 92 |
"""Verifies Firebase ID token from the Authorization header."""
|
| 93 |
if not auth_header or not auth_header.startswith('Bearer '):
|
|
|
|
| 88 |
# 2. HELPER FUNCTIONS & AUTHENTICATION
|
| 89 |
# -----------------------------------------------------------------------------
|
| 90 |
|
| 91 |
+
def _strip_json_fences(s: str) -> str:
|
| 92 |
+
"""Removes markdown code fences and cleans up AI string responses."""
|
| 93 |
+
s = (s or "").strip()
|
| 94 |
+
if "```" in s:
|
| 95 |
+
m = re.search(r"```(?:json)?\s*(.*?)\s*```", s, re.DOTALL)
|
| 96 |
+
if m: return m.group(1).strip()
|
| 97 |
+
return s
|
| 98 |
+
|
| 99 |
def verify_token(auth_header):
|
| 100 |
"""Verifies Firebase ID token from the Authorization header."""
|
| 101 |
if not auth_header or not auth_header.startswith('Bearer '):
|