rairo commited on
Commit
b2b867c
·
verified ·
1 Parent(s): 79f9b03

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -0
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 '):