From f28fa6c9c26c650719f0a385433c34374491d32b Mon Sep 17 00:00:00 2001 From: ENI Date: Sat, 14 Nov 2026 15:30:36 +0200 Subject: [PATCH] shim: separate theos_block counter in healthz; wave 100/100 accounts --- shim.py | 4 ++- tooltest.py | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ wave.log | 45 ++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 tooltest.py diff --git a/shim.py b/shim.py index 12c0aae..cfbd5ef 100644 --- a/shim.py +++ b/shim.py @@ -89,7 +89,7 @@ def call_upstream(model, payload, stream): if "Free daily Theos" in text or "Theos are not available" in text: with _lock: _state["modelcool"][(email, model)] = time.time() + 6 * 3600 - _state["fail"] += 1 + _state["theos_block"] = _state.get("theos_block", 0) + 1 continue # machine_required лечится пересчётом machine-id, а не сменой аккаунта if "machine_required" in text: @@ -126,6 +126,8 @@ class H(BaseHTTPRequestHandler): "accounts": len(recs), "cooling": sum(1 for r in recs if _state["cool"].get(r["email"], 0) > now), "requests_ok": _state["ok"], "requests_fail": _state["fail"], + "theos_block": _state.get("theos_block", 0), + "modelcool": len(_state["modelcool"]), }) return if self.path.startswith("/v1/models"): diff --git a/tooltest.py b/tooltest.py new file mode 100644 index 0000000..75bba0d --- /dev/null +++ b/tooltest.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +"""Проверка нативного tool use (function calling) у моделей пула DeepAI через new-api. + +Запуск на проде: python3 /tmp/tooltest.py [model1 model2 ...] +""" +import json +import sys +import urllib.request + +BASE = "http://127.0.0.1:48005/v1/chat/completions" +TOK = open("/tmp/tok.txt").read().strip() + +TOOLS = [{ + "type": "function", + "function": { + "name": "get_weather", + "description": "Get current weather for a city", + "parameters": { + "type": "object", + "properties": {"city": {"type": "string", "description": "city name"}}, + "required": ["city"], + }, + }, +}] + +DEFAULT_MODELS = [ + "claude-opus-5-5", "claude-sonnet-5-5", "gpt-6.1-sol", "gpt-6-astra", + "gemini-4-argon", "gemini-4-hydrogen", "kimi-k3.1-pro", "glm-5.3", + "minimax-m3", "qwen-3.8-max-prime", + "glm-5.3-flash", "gpt-6-luna", "deepseek-v4.1-flash", "mimo-2.6-flash", + "qwen-3.8-flash", "minimax-m3.1-flash", +] + + +def post(body, timeout=180): + req = urllib.request.Request( + BASE, data=json.dumps(body).encode(), + headers={"Authorization": "Bearer " + TOK, "Content-Type": "application/json"}) + with urllib.request.urlopen(req, timeout=timeout) as r: + return json.loads(r.read().decode()) + + +def test(model): + body = { + "model": model, + "messages": [{"role": "user", "content": "What's the weather in Paris? Use the tool."}], + "tools": TOOLS, "tool_choice": "auto", "max_tokens": 250, + } + try: + d = post(body) + except Exception as e: + return "ERR", str(e)[:90] + ch = (d.get("choices") or [{}])[0] + msg = ch.get("message") or {} + tc = msg.get("tool_calls") or [] + if not tc: + return "NO_TOOL", "finish=%s content=%r" % (ch.get("finish_reason"), (msg.get("content") or "")[:60]) + fn = tc[0].get("function") or {} + name = fn.get("name") + args = fn.get("arguments") + # round-trip: отдаём результат инструмента и ждём финальный текст + rt = "n/a" + try: + body2 = dict(body) + body2["messages"] = body["messages"] + [ + {"role": "assistant", "content": None, "tool_calls": tc}, + {"role": "tool", "tool_call_id": tc[0].get("id", "call_1"), + "content": json.dumps({"city": "Paris", "temp_c": 11, "sky": "cloudy"})}, + ] + body2.pop("tools", None) + d2 = post(body2) + c2 = ((d2.get("choices") or [{}])[0].get("message") or {}).get("content") or "" + rt = "rt_ok" if c2.strip() else "rt_empty" + except Exception as e: + rt = "rt_err:" + str(e)[:40] + return "TOOL", "%s(%s) %s" % (name, args, rt) + + +def main(): + models = sys.argv[1:] or DEFAULT_MODELS + res = {} + for m in models: + st, info = test(m) + res[m] = st + print("%-22s %-8s %s" % (m, st, info), flush=True) + ok = [m for m, s in res.items() if s == "TOOL"] + print("\nTOOL_SUPPORT %d/%d: %s" % (len(ok), len(res), ",".join(ok))) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/wave.log b/wave.log index 82cba97..9564b30 100644 --- a/wave.log +++ b/wave.log @@ -255,3 +255,48 @@ accounts=102 done=3 todo=100 workers=1 [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAMTH0 consent=Continue txt='loading\nsign in with google\nsign in to deepai\nbeverlyhigginxffao@ecolu' [85/100] OK BeverlyHigginxffao@ecolu.us balance=0.00000 [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAPnft consent=Continue txt='loading\nsign in with google\nsign in to deepai\nrosalindmayuob0z@ecolu.u' +[86/100] OK RosalindMayuob0z@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAP4lh consent=Continue txt='loading\nsign in with google\nsign in to deepai\nemelinacoffman27w1x@ecol' +[87/100] OK EmelinaCoffman27w1x@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAOw1o consent=Continue txt='loading\nsign in with google\nsign in to deepai\neddiehortonldp8u@ecolu.u' +[88/100] OK EddieHortonldp8u@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAOpTe consent=Continue txt='loading\nsign in with google\nsign in to deepai\nbetseytang9p85s@ecolu.us' +[89/100] OK BetseyTang9p85s@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hANhi- consent=Continue txt='loading\nsign in with google\nsign in to deepai\ncarittaperson6n02z@ecolu' +[90/100] OK CarittaPerson6n02z@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAN8Bk consent=Continue txt='loading\nsign in with google\nsign in to deepai\nmommywaltonri2dg@ecolu.u' +[91/100] OK MommyWaltonri2dg@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAN1iW consent=Continue txt='loading\nsign in with google\nsign in to deepai\njohannacoffeye60en@ecolu' +[92/100] OK JohannaCoffeye60en@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAN6YN consent=Continue txt='loading\nsign in with google\nsign in to deepai\ndesiriwaldronw8mkx@ecolu' +[93/100] OK DesiriWaldronw8mkx@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAP9wM consent=Continue txt='loading\nsign in with google\nsign in to deepai\ngwynwolffr88z7@ecolu.us\n' +[94/100] OK GwynWolffr88z7@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAOZOr consent=Continue txt='loading\nsign in with google\nsign in to deepai\nmollimartinezcxope@ecolu' +[95/100] OK MolliMartinezcxope@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAOde8 consent=Continue txt='loading\nsign in with google\nsign in to deepai\ncarlinaclinetpsmr@ecolu.' +[96/100] OK CarlinaClinetpsmr@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAOQRv consent=Continue txt='loading\nsign in with google\nsign in to deepai\nmalaheathr3v3j@ecolu.us\n' +[97/100] OK MalaHeathr3v3j@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAPARZ consent=Continue txt='loading\nsign in with google\nsign in to deepai\nviolantetravimqhap@ecolu' +[98/100] OK ViolanteTravimqhap@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAMJbD consent=Continue txt='loading\nsign in with google\nsign in to deepai\norlybunnell69g21@ecolu.u' +[99/100] OK OrlyBunnell69g21@ecolu.us balance=0.00000 + [r2] https://accounts.google.com/v3/signin/speedbump/workspacetermsofservic consent=Понятно txt='загрузка...\nдобро пожаловать!\nдобро пожаловать в ваш новый аккаунт\nу в' + [r3] https://accounts.google.com/signin/oauth/id?authuser=0&part=AJi8hAOH1v consent=Continue txt='loading\nsign in with google\nsign in to deepai\ncorrinarandolphbi8ja@eco' +[100/100] OK CorrinaRandolphbi8ja@ecolu.us balance=0.00000 +DONE ok=100 fail=0