File size: 2,410 Bytes
92698bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | """Confirm thinking is disabled and params are correct."""
import os, json, requests, time
os.chdir(os.path.dirname(os.path.abspath(__file__)))
from backend.chat import ChatHandler
from backend.memory import DatabaseManager
from backend.config import config
# Show current settings
print("=== Current config ===")
print(f" Model : {config.LLM_MODEL}")
print(f" Thinking : {config.LLM_ENABLE_THINKING}")
print(f" Temperature : {config.LLM_TEMPERATURE}")
print(f" Top-p : {config.LLM_TOP_P}")
print(f" Top-k : {config.LLM_TOP_K}")
print(f" Presence penalty: {config.LLM_PRESENCE_PENALTY}")
print(f" Max tokens : {config.LLM_MAX_TOKENS}")
# Fire a direct call to verify
print("\n=== Live call ===")
HEADERS = {"Content-Type": "application/json",
"Authorization": f"Bearer {config.ATLASCLOUD_API_KEY}"}
handler = ChatHandler.__new__(ChatHandler)
handler.api_url = "https://api.atlascloud.ai/v1/chat/completions"
handler.headers = HEADERS
handler.db = None # not needed for this test
msgs = [{"role": "user", "content": "In one sentence: what is your motto?"}]
payload = handler._build_payload(msgs, stream=True)
print(f" Payload keys: {list(payload.keys())}")
print(f" enable_thinking in payload: {payload.get('enable_thinking')}")
t0 = time.time()
r = requests.post(handler.api_url, headers=HEADERS, json=payload,
stream=True, timeout=(30, 120))
print(f" HTTP {r.status_code}")
thinking_chars, content = 0, ""
first_token_at = None
for line in r.iter_lines():
if not line: continue
txt = line.decode()
if not txt.startswith("data: "): continue
raw = txt[6:].strip()
if raw == "[DONE]": break
try:
d = json.loads(raw)
delta = d["choices"][0].get("delta", {})
rc = delta.get("reasoning_content", "")
c = delta.get("content", "")
if rc: thinking_chars += len(rc)
if c:
if first_token_at is None: first_token_at = time.time() - t0
content += c
except: pass
elapsed = time.time() - t0
print(f" Time to first token : {first_token_at:.1f}s")
print(f" Total time : {elapsed:.1f}s")
print(f" Thinking chars : {thinking_chars} {'(NONE - thinking OFF)' if not thinking_chars else '(THINKING IS STILL ON!)'}")
print(f" Response : {content}")
|