Merge dev into main for testing

This commit is contained in:
pewdiepie-archdaemon
2026-06-28 14:07:23 +00:00
236 changed files with 17610 additions and 9212 deletions
+10 -8
View File
@@ -14,6 +14,7 @@ These are agent tools — the LLM writes fenced code blocks and they execute
through the standard agent_tools.py pipeline.
"""
import asyncio
import json
import logging
import uuid
@@ -134,7 +135,8 @@ def _resolve_model(spec: str, owner: Optional[str] = None) -> Tuple[str, str, Di
r = httpx.get(models_url, headers=headers, timeout=5)
r.raise_for_status()
data = r.json()
model_ids = [m.get("id") for m in (data.get("data") or []) if m.get("id")]
items = data if isinstance(data, list) else (data.get("data") or [])
model_ids = [m.get("id") for m in items if isinstance(m, dict) and m.get("id")]
if not model_ids:
model_ids = [
m.get("name") or m.get("model")
@@ -228,7 +230,7 @@ async def do_pipeline(content: str, session_id: Optional[str] = None, owner: Opt
if not model_spec or not instruction:
return {"error": f"Step {i + 1}: both 'model' and 'instruction' are required"}
try:
url, model, headers = _resolve_model(model_spec, owner=owner)
url, model, headers = await asyncio.to_thread(_resolve_model, model_spec, owner=owner)
resolved.append((url, model, headers, instruction))
except ValueError as e:
return {"error": f"Step {i + 1}: {e}"}
@@ -463,8 +465,6 @@ async def do_manage_memory(content: str, session_id: Optional[str] = None, owner
return {"error": f"Unknown action '{action}'. Use: list, add, edit, delete, search"}
# ---------------------------------------------------------------------------
# RAG management tool
# ---------------------------------------------------------------------------
@@ -635,7 +635,7 @@ async def do_ui_control(content: str, session_id: Optional[str] = None, owner: O
# Resolve the model to validate it exists
try:
url, model_id, headers = _resolve_model(model_spec, owner=owner)
url, model_id, headers = await asyncio.to_thread(_resolve_model, model_spec, owner=owner)
except ValueError as e:
return {"error": str(e)}
@@ -925,7 +925,7 @@ async def do_generate_image(content: str, session_id: Optional[str] = None, owne
if not model_spec:
for candidate in ("gpt-image-1.5", "gpt-image-1", "dall-e-3"):
try:
_resolve_model(candidate, owner=owner)
await asyncio.to_thread(_resolve_model, candidate, owner=owner)
model_spec = candidate
break
except ValueError:
@@ -952,7 +952,9 @@ async def do_generate_image(content: str, session_id: Optional[str] = None, owne
try:
_r = _req.get(_ibase + "/models", timeout=3)
_r.raise_for_status()
_mids = [m.get("id") for m in (_r.json().get("data") or []) if m.get("id")]
_data = _r.json()
_ditems = _data if isinstance(_data, list) else (_data.get("data") or [])
_mids = [m.get("id") for m in _ditems if isinstance(m, dict) and m.get("id")]
if _mids:
model_spec = _mids[0]
break
@@ -967,7 +969,7 @@ async def do_generate_image(content: str, session_id: Optional[str] = None, owne
# Resolve the model to find the right endpoint
try:
url, model_id, headers = _resolve_model(model_spec, owner=owner)
url, model_id, headers = await asyncio.to_thread(_resolve_model, model_spec, owner=owner)
except ValueError:
return {"error": f"No endpoint found with image model '{model_spec}'. "
"Configure an OpenAI-compatible endpoint with image generation support."}