agentram 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agentram/orchestration.py +8 -1
- package/package.json +1 -1
- package/pyproject.toml +1 -1
|
@@ -4,6 +4,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
4
4
|
from dataclasses import dataclass, field
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
|
+
import re
|
|
7
8
|
import shlex
|
|
8
9
|
import subprocess
|
|
9
10
|
import urllib.error
|
|
@@ -219,4 +220,10 @@ def parse_openai_sse(raw: str) -> str:
|
|
|
219
220
|
message = choice.get("message", {})
|
|
220
221
|
if isinstance(message, dict) and message.get("content"):
|
|
221
222
|
parts.append(str(message.get("content")))
|
|
222
|
-
return "".join(parts).strip()
|
|
223
|
+
return strip_thinking_blocks("".join(parts)).strip()
|
|
224
|
+
|
|
225
|
+
def strip_thinking_blocks(text: str) -> str:
|
|
226
|
+
text = re.sub(r"<thinking>.*?</thinking>", "", text, flags=re.DOTALL | re.IGNORECASE)
|
|
227
|
+
text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL | re.IGNORECASE)
|
|
228
|
+
text = re.sub(r"^\s*</?(thinking|think)>\s*", "", text, flags=re.IGNORECASE)
|
|
229
|
+
return text.strip()
|
package/package.json
CHANGED