Implement StepFun Realtime service and enhance AssistantConfig

- Add new fields to AssistantConfig for realtime interface configuration, including types, values, and secrets.
- Introduce StepFunRealtimeService to handle speech-to-speech processing via WebSocket, integrating STT, LLM, and TTS functionalities.
- Refactor pipeline execution to support a new realtime mode, allowing direct text input processing and immediate responses.
- Update model resource testing to include validation for StepFun Realtime connections.
- Enhance service factory to create realtime services based on configuration settings.
- Modify README documentation to reflect new realtime capabilities and usage instructions.
This commit is contained in:
Xin Wang
2026-06-14 23:41:40 +08:00
parent d55b87cfbf
commit 0309c154b5
11 changed files with 612 additions and 19 deletions

View File

@@ -59,6 +59,15 @@ def _resource_out(row: ModelResource) -> ModelResourceOut:
)
async def _commit_resource(
session: AsyncSession, row: ModelResource
) -> ModelResourceOut:
"""Commit and reload server-generated fields before serializing the row."""
await session.commit()
await session.refresh(row)
return _resource_out(row)
async def _definition(
session: AsyncSession, interface_type: str
) -> InterfaceDefinition:
@@ -141,8 +150,7 @@ async def create_model_resource(
.where(ModelResource.capability == row.capability, ModelResource.id != row.id)
.values(is_default=False)
)
await session.commit()
return _resource_out(row)
return await _commit_resource(session, row)
@router.post("/model-resources/test", response_model=ModelResourceTestResult)
@@ -196,8 +204,7 @@ async def duplicate_model_resource(
is_default=False,
)
session.add(row)
await session.commit()
return _resource_out(row)
return await _commit_resource(session, row)
@router.put("/model-resources/{resource_id}", response_model=ModelResourceOut)
@@ -224,8 +231,7 @@ async def update_model_resource(
.where(ModelResource.capability == row.capability, ModelResource.id != row.id)
.values(is_default=False)
)
await session.commit()
return _resource_out(row)
return await _commit_resource(session, row)
@router.delete("/model-resources/{resource_id}")

View File

@@ -58,7 +58,9 @@ async def voice_signaling(websocket: WebSocket):
except Exception as e:
logger.error(f"WebRTC 信令出错: {e}")
finally:
for pc in peers.values():
# disconnect() triggers the registered closed callback, which removes
# the peer from this dict. Iterate over a snapshot to avoid mutation.
for pc in list(peers.values()):
await pc.disconnect()