Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,7 +40,7 @@ except ImportError: WHISPER_AVAILABLE = False; print("WARNING: OpenAI Whisper no
|
|
| 40 |
|
| 41 |
# --- google-genai SDK (Unified SDK) ---
|
| 42 |
from google import genai as google_genai_sdk # Alias for clarity
|
| 43 |
-
from
|
| 44 |
# For FileState enum later
|
| 45 |
from google.ai import generativelanguage as glm
|
| 46 |
# --- End google-genai SDK ---
|
|
@@ -150,13 +150,10 @@ def _strip_exact_match_answer(text: Any) -> str:
|
|
| 150 |
if text_lower_check.startswith("final answer:"):
|
| 151 |
text = text[len("final answer:"):].strip()
|
| 152 |
text = text.strip()
|
| 153 |
-
if text.startswith("
|
| 154 |
-
") and text.endswith("
|
| 155 |
-
"):
|
| 156 |
if "\n" in text:
|
| 157 |
text_content = text.split("\n", 1)[1] if len(text.split("\n", 1)) > 1 else ""
|
| 158 |
-
text = text_content.strip()[:-3].strip() if text_content.strip().endswith("
|
| 159 |
-
") else text[3:-3].strip()
|
| 160 |
else: text = text[3:-3].strip()
|
| 161 |
elif text.startswith("`") and text.endswith("`"): text = text[1:-1].strip()
|
| 162 |
if (text.startswith('"') and text.endswith('"')) or \
|
|
@@ -671,4 +668,4 @@ if __name__ == "__main__":
|
|
| 671 |
|
| 672 |
logger.info(f"Space ID: {os.getenv('SPACE_ID', 'Not Set')}")
|
| 673 |
logger.info("Gradio Interface launching...")
|
| 674 |
-
demo.queue().launch(debug=os.getenv("GRADIO_DEBUG","false").lower()=="true", share=False, max_threads=20)
|
|
|
|
| 40 |
|
| 41 |
# --- google-genai SDK (Unified SDK) ---
|
| 42 |
from google import genai as google_genai_sdk # Alias for clarity
|
| 43 |
+
from genai.types import HarmCategory, HarmBlockThreshold # ***** CORRECTED IMPORT *****
|
| 44 |
# For FileState enum later
|
| 45 |
from google.ai import generativelanguage as glm
|
| 46 |
# --- End google-genai SDK ---
|
|
|
|
| 150 |
if text_lower_check.startswith("final answer:"):
|
| 151 |
text = text[len("final answer:"):].strip()
|
| 152 |
text = text.strip()
|
| 153 |
+
if text.startswith("```") and text.endswith("```"):
|
|
|
|
|
|
|
| 154 |
if "\n" in text:
|
| 155 |
text_content = text.split("\n", 1)[1] if len(text.split("\n", 1)) > 1 else ""
|
| 156 |
+
text = text_content.strip()[:-3].strip() if text_content.strip().endswith("```") else text[3:-3].strip()
|
|
|
|
| 157 |
else: text = text[3:-3].strip()
|
| 158 |
elif text.startswith("`") and text.endswith("`"): text = text[1:-1].strip()
|
| 159 |
if (text.startswith('"') and text.endswith('"')) or \
|
|
|
|
| 668 |
|
| 669 |
logger.info(f"Space ID: {os.getenv('SPACE_ID', 'Not Set')}")
|
| 670 |
logger.info("Gradio Interface launching...")
|
| 671 |
+
demo.queue().launch(debug=os.getenv("GRADIO_DEBUG","false").lower()=="true", share=False, max_threads=20)
|