refactor: remove legacy assistant compatibility
This commit is contained in:
@@ -63,24 +63,23 @@ async def _wait_for_pipeline_close(
|
||||
|
||||
|
||||
async def shutdown_active_sessions() -> None:
|
||||
"""Compatibility proxy; now drains RTVI and OpenAI Realtime sessions."""
|
||||
"""Drain RTVI and OpenAI Realtime sessions."""
|
||||
_http_peers.clear()
|
||||
await realtime_lifecycle.shutdown_active_sessions(
|
||||
timeout=PIPELINE_CLOSE_GRACE_SECONDS,
|
||||
)
|
||||
|
||||
|
||||
def _decode_client_tool_names(encoded: str | None) -> list[str] | None:
|
||||
def _decode_client_tool_names(encoded: str | None) -> list[str]:
|
||||
"""Decode client capabilities carried outside the WebRTC SDP body.
|
||||
|
||||
Pipecat's browser transport replaces the body of a ``Request`` endpoint
|
||||
with its SDP offer and drops ``APIRequest.requestData``. Request headers are
|
||||
preserved, so they are the authoritative metadata channel for this path.
|
||||
``None`` means the header was absent and callers should use the legacy body.
|
||||
preserved, so they are the single metadata channel for this path.
|
||||
"""
|
||||
|
||||
if encoded is None:
|
||||
return None
|
||||
return []
|
||||
try:
|
||||
padding = "=" * (-len(encoded) % 4)
|
||||
value = json.loads(
|
||||
@@ -134,21 +133,16 @@ async def http_offer(request: Request, payload: dict = Body(...)):
|
||||
header_variables = json.loads(
|
||||
base64.urlsafe_b64decode(encoded_variables + padding).decode("utf-8")
|
||||
)
|
||||
header_client_tools = _decode_client_tool_names(
|
||||
client_tool_names = _decode_client_tool_names(
|
||||
request.headers.get("x-pipecat-client-tools")
|
||||
)
|
||||
client_tool_names = (
|
||||
header_client_tools
|
||||
if header_client_tools is not None
|
||||
else request_data.get("client_tool_names") or []
|
||||
)
|
||||
logger.debug(f"WebRTC 客户端工具上报: {client_tool_names or '<none>'}")
|
||||
offer_payload = {
|
||||
**payload,
|
||||
"assistant_id": request.headers.get("x-pipecat-assistant-id"),
|
||||
"dynamic_variables": header_variables,
|
||||
**request_data,
|
||||
# Keep header metadata authoritative when both paths are present.
|
||||
# Client capabilities have one canonical transport: the request header.
|
||||
"client_tool_names": client_tool_names,
|
||||
}
|
||||
answer = await _handle_offer_payload(offer_payload, _http_peers)
|
||||
|
||||
Reference in New Issue
Block a user