INNER CODE UNIT · Python

display_usage

usepr/eva · eva.py:460

def display_usage(usage, cap):
    t = usage.get('total_tokens', 0) if usage else 0
    if t == 0 or cap <= 0:
        return
    
    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:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…