fix(teamsbot): SSE rate-limit 60/min, TTS message format for bot protocol
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
729c6355b5
commit
02dedc972d
2 changed files with 8 additions and 4 deletions
|
|
@ -242,7 +242,7 @@ async def getSession(
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{instanceId}/sessions/{sessionId}/stream")
|
@router.get("/{instanceId}/sessions/{sessionId}/stream")
|
||||||
@limiter.limit("10/minute")
|
@limiter.limit("60/minute")
|
||||||
async def streamSession(
|
async def streamSession(
|
||||||
request: Request,
|
request: Request,
|
||||||
instanceId: str,
|
instanceId: str,
|
||||||
|
|
|
||||||
|
|
@ -497,10 +497,14 @@ class TeamsbotService:
|
||||||
audioContent = ttsResult.get("audioContent")
|
audioContent = ttsResult.get("audioContent")
|
||||||
if audioContent and websocket:
|
if audioContent and websocket:
|
||||||
# Send TTS audio to bot via WebSocket
|
# Send TTS audio to bot via WebSocket
|
||||||
|
# Bot expects: {type: "playAudio", sessionId, audio: {data, format}}
|
||||||
await websocket.send_text(json.dumps({
|
await websocket.send_text(json.dumps({
|
||||||
"type": "tts_audio",
|
"type": "playAudio",
|
||||||
|
"sessionId": sessionId,
|
||||||
|
"audio": {
|
||||||
"data": base64.b64encode(audioContent if isinstance(audioContent, bytes) else audioContent.encode()).decode(),
|
"data": base64.b64encode(audioContent if isinstance(audioContent, bytes) else audioContent.encode()).decode(),
|
||||||
"format": "mp3",
|
"format": "mp3",
|
||||||
|
},
|
||||||
}))
|
}))
|
||||||
elif audioContent and not websocket:
|
elif audioContent and not websocket:
|
||||||
logger.info(f"TTS audio generated for session {sessionId} (HTTP mode - no WebSocket for playback)")
|
logger.info(f"TTS audio generated for session {sessionId} (HTTP mode - no WebSocket for playback)")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue