update
This commit is contained in:
@@ -82,11 +82,12 @@ async def _api_slot(key: str) -> None:
|
||||
|
||||
|
||||
class AgentErgebnis:
|
||||
__slots__ = ("rc", "text", "err", "tokens", "wait_s")
|
||||
__slots__ = ("rc", "text", "err", "tokens", "wait_s", "model")
|
||||
|
||||
def __init__(self, rc: int, text: str, err: str, tokens: dict | None = None):
|
||||
self.rc, self.text, self.err, self.tokens = rc, text, err, tokens or {}
|
||||
self.wait_s = 0.0 # Queue-Zeit (Semaphore/Drossel) — run_agent füllt sie
|
||||
self.model = "" # aufgelöstes Modell — run_agent füllt es (Ledger)
|
||||
|
||||
@property
|
||||
def ok(self) -> bool:
|
||||
@@ -161,12 +162,13 @@ async def run_agent(key: str, prompt: str, timeout: int, *, provider: str,
|
||||
await _api_slot(key)
|
||||
wait_s = time.time() - warte_start
|
||||
try:
|
||||
res = await _text_api(key, prompt, timeout, model)
|
||||
res = await _text_api(key, prompt, timeout, model, role)
|
||||
finally:
|
||||
_api_inflight -= 1
|
||||
if res.rc == 0:
|
||||
_erfolg_melden()
|
||||
res.wait_s = wait_s
|
||||
res.model = model
|
||||
return res
|
||||
await _drossel_warten(key)
|
||||
wait_s = time.time() - warte_start
|
||||
@@ -175,6 +177,7 @@ async def run_agent(key: str, prompt: str, timeout: int, *, provider: str,
|
||||
else:
|
||||
res = await _claude_cli(key, prompt, timeout, model, capabilities)
|
||||
res.wait_s = wait_s
|
||||
res.model = model
|
||||
return res
|
||||
finally:
|
||||
_active.pop(key, None)
|
||||
@@ -335,12 +338,20 @@ _API_MODEL_OPTS = {
|
||||
# Antwort nach bis zu 44 min — Extraktion war 53 von 63 min der Ebene).
|
||||
"minimax-kalt/MiniMax-M2.7-highspeed": {"temperature": 0.3,
|
||||
"thinking": {"type": "disabled"}},
|
||||
# native Route (judge/guide): ungedrosselt liefen Merge-Judges ins Output-Cap
|
||||
# (58–71 % Parse-Fehler). role=guide (Writer) behält Thinking — _text_api
|
||||
# nimmt die thinking-Option dort wieder raus.
|
||||
"minimax/MiniMax-M3": {"temperature": 0.2, "thinking": {"type": "disabled"}},
|
||||
}
|
||||
|
||||
|
||||
async def _text_api(key: str, prompt: str, timeout: int, model: str) -> AgentErgebnis:
|
||||
async def _text_api(key: str, prompt: str, timeout: int, model: str,
|
||||
role: str = "judge") -> AgentErgebnis:
|
||||
opts = dict(_API_MODEL_OPTS.get(model, {}))
|
||||
if role == "guide":
|
||||
opts.pop("thinking", None) # Writer braucht Denkraum — nur Judges kalt
|
||||
body = {"model": model.split("/", 1)[1], "max_tokens": _API_MAX_TOKENS,
|
||||
"messages": [{"role": "user", "content": prompt}], **_API_MODEL_OPTS.get(model, {})}
|
||||
"messages": [{"role": "user", "content": prompt}], **opts}
|
||||
headers = {"x-api-key": os.environ.get("MINIMAX_API_KEY", ""), "anthropic-version": "2023-06-01"}
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=httpx.Timeout(timeout, connect=30)) as client:
|
||||
|
||||
Reference in New Issue
Block a user