Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -226,6 +226,12 @@ class LLMService:
|
|
| 226 |
api_key=os.getenv("HF_TOKEN"),
|
| 227 |
)
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
def ask(self, model_id, system_prompt, user_input, provider=None):
|
| 230 |
messages = [
|
| 231 |
{"role": "system", "content": system_prompt},
|
|
@@ -241,7 +247,8 @@ class LLMService:
|
|
| 241 |
stream=False,
|
| 242 |
extra_headers=extra_headers,
|
| 243 |
)
|
| 244 |
-
|
|
|
|
| 245 |
except Exception as e:
|
| 246 |
return f"🚨 Fehler ({model_id}): {str(e)}"
|
| 247 |
|
|
@@ -457,6 +464,7 @@ with gr.Blocks() as demo:
|
|
| 457 |
chatbot = gr.Chatbot(
|
| 458 |
label="Sitzungsprotokoll",
|
| 459 |
height=700,
|
|
|
|
| 460 |
)
|
| 461 |
clear_btn.add(chatbot)
|
| 462 |
|
|
|
|
| 226 |
api_key=os.getenv("HF_TOKEN"),
|
| 227 |
)
|
| 228 |
|
| 229 |
+
@staticmethod
|
| 230 |
+
def _strip_thinking(text: str) -> str:
|
| 231 |
+
"""Entfernt <think>...</think> Blöcke (z.B. von DeepSeek-R1) aus dem Output."""
|
| 232 |
+
import re
|
| 233 |
+
return re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL).strip()
|
| 234 |
+
|
| 235 |
def ask(self, model_id, system_prompt, user_input, provider=None):
|
| 236 |
messages = [
|
| 237 |
{"role": "system", "content": system_prompt},
|
|
|
|
| 247 |
stream=False,
|
| 248 |
extra_headers=extra_headers,
|
| 249 |
)
|
| 250 |
+
raw = response.choices[0].message.content or ""
|
| 251 |
+
return self._strip_thinking(raw)
|
| 252 |
except Exception as e:
|
| 253 |
return f"🚨 Fehler ({model_id}): {str(e)}"
|
| 254 |
|
|
|
|
| 464 |
chatbot = gr.Chatbot(
|
| 465 |
label="Sitzungsprotokoll",
|
| 466 |
height=700,
|
| 467 |
+
sanitize_html=False,
|
| 468 |
)
|
| 469 |
clear_btn.add(chatbot)
|
| 470 |
|