fix: thinking hart deaktiviert + leere think-tags entfernt (Crash-Fix) + Terminal-Chat-Client

This commit is contained in:
2026-07-15 14:52:44 +02:00
parent 6989590ab1
commit 90fe263aab
2 changed files with 60 additions and 3 deletions
+2 -3
View File
@@ -353,8 +353,7 @@ def render_chat(messages, enable_thinking=False, reasoning_effort=None, tools=No
raise APIError(400, f"Unsupported message role: {role!r}.",
f"messages.{index}.role", "unsupported_role")
prev_tool = (role == "tool")
prompt.append("<|assistant|><think>" if enable_thinking else
"<|assistant|><think></think>")
prompt.append('<|assistant|>' if not enable_thinking else '<|assistant|><think>')
return "".join(prompt)
@@ -950,7 +949,7 @@ class APIHandler(BaseHTTPRequestHandler):
if (reasoning_effort is None and "enable_thinking" not in body
and os.environ.get("COLI_THINK", "0") == "1"):
reasoning_effort = "high"
enable_thinking = body.get("enable_thinking", reasoning_effort not in (None, "none"))
enable_thinking = False # FORCED OFF by Cody
if not isinstance(enable_thinking, bool):
raise APIError(400, "`enable_thinking` must be a boolean.", "enable_thinking")
tools = body.get("tools") or body.get("functions") or None
Executable
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""Interaktiver Chat mit Colibri GLM-5.2 — direkt im Terminal."""
import urllib.request, json, sys, os
API = "http://127.0.0.1:8082/v1/chat/completions"
KEY = "colibri-glm52-local"
MODEL = "glm-5.2"
HISTORY = []
print("\033[1;36m╔══════════════════════════════════╗")
print("║ Colibri GLM-5.2 — Terminal ║")
print("║ /quit • /clear • /help ║")
print("╚══════════════════════════════════╝\033[0m\n")
while True:
try:
user = input("\033[1;33mDu>\033[0m ")
except (EOFError, KeyboardInterrupt):
print("\n\033[2mTschüss!\033[0m")
break
if user.strip().lower() in ("/quit", "/exit", "/q"):
print("\033[2mTschüss!\033[0m")
break
if user.strip().lower() == "/clear":
HISTORY.clear()
print("\033[2mVerlauf gelöscht.\033[0m")
continue
if user.strip().lower() == "/help":
print(" /quit • Beenden\n /clear • Verlauf löschen\n /help • Hilfe")
continue
if not user.strip():
continue
HISTORY.append({"role": "user", "content": user})
data = json.dumps({
"model": MODEL,
"messages": HISTORY[-30:], # Letzte 30 Nachrichten
"max_tokens": 512,
"stream": False
}).encode()
req = urllib.request.Request(API, data=data, headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {KEY}"
})
print("\033[2m⏳\033[0m", end="", flush=True)
try:
resp = urllib.request.urlopen(req, timeout=300)
j = json.loads(resp.read().decode())
text = j["choices"][0]["message"]["content"]
print(f"\r\033[1;36mGLM>\033[0m {text}")
HISTORY.append({"role": "assistant", "content": text})
except Exception as e:
print(f"\r\033[1;31mFehler:\033[0m {e}")
HISTORY.pop() # Fehlgeschlagenen Request entfernen