Spaces:
Sleeping
Sleeping
Update src/components/ai_core_async_methods.py
Browse files
src/components/ai_core_async_methods.py
CHANGED
|
@@ -184,19 +184,27 @@ def _generate_model_response(self, prompt: str) -> str:
|
|
| 184 |
if len(response_parts) > 1:
|
| 185 |
response = response_parts[1].strip()
|
| 186 |
|
| 187 |
-
# Filter out system messages and protected content (
|
| 188 |
system_markers = [
|
| 189 |
-
'[Protected:', '[System:', '[System
|
| 190 |
]
|
| 191 |
|
| 192 |
lines = response.split('\n')
|
| 193 |
filtered_lines = []
|
| 194 |
for line in lines:
|
| 195 |
-
#
|
| 196 |
if any(marker in line for marker in system_markers):
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
response = '\n'.join(filtered_lines).strip() # Use newline join, not space
|
| 202 |
|
|
|
|
| 184 |
if len(response_parts) > 1:
|
| 185 |
response = response_parts[1].strip()
|
| 186 |
|
| 187 |
+
# Filter out system messages and protected content (strip markers from text)
|
| 188 |
system_markers = [
|
| 189 |
+
'[Protected:', '[System:', '[System optimized response]',
|
| 190 |
]
|
| 191 |
|
| 192 |
lines = response.split('\n')
|
| 193 |
filtered_lines = []
|
| 194 |
for line in lines:
|
| 195 |
+
# Skip lines that are purely system markers
|
| 196 |
if any(marker in line for marker in system_markers):
|
| 197 |
+
# Try to extract content after marker instead of skipping entirely
|
| 198 |
+
cleaned_line = line
|
| 199 |
+
for marker in system_markers:
|
| 200 |
+
if marker in cleaned_line:
|
| 201 |
+
# Remove the marker from the line
|
| 202 |
+
cleaned_line = cleaned_line.replace(marker, '').strip()
|
| 203 |
+
if cleaned_line: # Only add if something remains
|
| 204 |
+
filtered_lines.append(cleaned_line)
|
| 205 |
+
else:
|
| 206 |
+
# Keep lines without markers as-is
|
| 207 |
+
filtered_lines.append(line)
|
| 208 |
|
| 209 |
response = '\n'.join(filtered_lines).strip() # Use newline join, not space
|
| 210 |
|