Spaces:
Running
Running
Add missing parse_thinking_blocks function
Browse filesFunction was referenced in summarize_streaming but never defined in app.py.
Copied from summarize_transcript.py.
app.py
CHANGED
|
@@ -56,15 +56,26 @@ def load_model():
|
|
| 56 |
raise
|
| 57 |
|
| 58 |
|
| 59 |
-
def
|
| 60 |
-
"""
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
def summarize_streaming(file_obj, max_tokens: int = 512, temperature: float = 0.6) -> Generator[str, None, None]:
|
|
|
|
| 56 |
raise
|
| 57 |
|
| 58 |
|
| 59 |
+
def parse_thinking_blocks(content: str) -> Tuple[str, str]:
|
| 60 |
+
"""
|
| 61 |
+
Parse thinking blocks from model output.
|
| 62 |
+
|
| 63 |
+
Args:
|
| 64 |
+
content: Full model response
|
| 65 |
+
|
| 66 |
+
Returns:
|
| 67 |
+
Tuple of (thinking_content, summary_content)
|
| 68 |
+
"""
|
| 69 |
+
pattern = r'<thinking>(.*?)</thinking>'
|
| 70 |
+
matches = re.findall(pattern, content, re.DOTALL)
|
| 71 |
+
|
| 72 |
+
if not matches:
|
| 73 |
+
return ("", content)
|
| 74 |
+
|
| 75 |
+
thinking = '\n\n'.join(match.strip() for match in matches)
|
| 76 |
+
summary = re.sub(pattern, '', content, flags=re.DOTALL).strip()
|
| 77 |
+
|
| 78 |
+
return (thinking, summary)
|
| 79 |
|
| 80 |
|
| 81 |
def summarize_streaming(file_obj, max_tokens: int = 512, temperature: float = 0.6) -> Generator[str, None, None]:
|