INNER CODE UNIT · Python

p

usepr/eva · eva.py:465

    p = min(t / cap, 1.0)
    bar = '█' * int(p*20) + '░' * (20-int(p*20))
    print(f"\033[2mCTX [{bar}] {p:.0%}  ({t//1000}k/{cap//1000}k)\033[0m")

def llm_chat(messages, tools=None, temperature=0.6, thinking=True):
    url = f"{EVA_BASE_URL}/chat/completions"
    data = _build_request_data(messages, tools, temperature, thinking, stream=False)
    body = json.dumps(data).encode('utf-8')
    req = urllib.request.Request(
        url, data=body,
        headers={**COMMON_HEADER, "Content-Type": "application/json"}
    )
    try:
        with urllib.request.urlopen(req) as resp:
            out = json.loads(resp.read().decode('utf-8', errors='replace'))
    except urllib.error.HTTPError as e:
        raw = e.read().decode('utf-8', errors='replace')
        raise Exception(f"HTTP {e.code}: {raw}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…