Add wait_for_response functionality to ToolResource and related components. Update API models, schemas, and routers to support new parameter. Enhance UI components to manage wait_for_response state, ensuring proper integration across the application.

This commit is contained in:
Xin Wang
2026-02-27 16:54:39 +08:00
parent 95c6e93a9c
commit 229243e832
9 changed files with 303 additions and 44 deletions

View File

@@ -22,7 +22,13 @@ from ..schemas import (
AssistantOpenerAudioGenerateRequest,
AssistantOpenerAudioOut,
)
from .tools import TOOL_REGISTRY, TOOL_CATEGORY_MAP, TOOL_PARAMETER_DEFAULTS, _ensure_tool_resource_schema
from .tools import (
TOOL_REGISTRY,
TOOL_CATEGORY_MAP,
TOOL_PARAMETER_DEFAULTS,
TOOL_WAIT_FOR_RESPONSE_DEFAULTS,
_ensure_tool_resource_schema,
)
router = APIRouter(prefix="/assistants", tags=["Assistants"])
@@ -142,6 +148,11 @@ def _resolve_runtime_tools(db: Session, selected_tool_ids: List[str], warnings:
)
defaults_raw = resource.parameter_defaults if resource else TOOL_PARAMETER_DEFAULTS.get(tool_id)
defaults = dict(defaults_raw) if isinstance(defaults_raw, dict) else {}
wait_for_response = (
bool(resource.wait_for_response)
if resource
else bool(TOOL_WAIT_FOR_RESPONSE_DEFAULTS.get(tool_id, False))
)
if not resource and tool_id not in TOOL_REGISTRY:
warnings.append(f"Tool resource not found: {tool_id}")
@@ -160,6 +171,7 @@ def _resolve_runtime_tools(db: Session, selected_tool_ids: List[str], warnings:
},
"displayName": display_name or tool_id,
"toolId": tool_id,
"waitForResponse": wait_for_response,
}
if defaults:
runtime_tool["defaultArgs"] = defaults