From 514d9c5238029bab4dfcca19cd7564b34d54f51c Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 12 Jan 2026 18:04:10 +0530 Subject: [PATCH] feat: enable Sarvam Models --- api/routes/public_agent.py | 2 +- api/routes/telephony.py | 9 +++++++- api/services/configuration/registry.py | 30 +++++++++++++------------- pipecat | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/api/routes/public_agent.py b/api/routes/public_agent.py index 97501e9..23c6578 100644 --- a/api/routes/public_agent.py +++ b/api/routes/public_agent.py @@ -166,7 +166,7 @@ async def initiate_call( workflow_run_id=workflow_run.id, ) except Exception as e: - logger.error( + logger.warning( f"Failed to initiate call for workflow run {workflow_run.id}: {e}" ) raise HTTPException( diff --git a/api/routes/telephony.py b/api/routes/telephony.py index cd7eb35..92c71fc 100644 --- a/api/routes/telephony.py +++ b/api/routes/telephony.py @@ -14,6 +14,7 @@ from pydantic import BaseModel from sqlalchemy import text from sqlalchemy.future import select from starlette.responses import HTMLResponse +from starlette.websockets import WebSocketDisconnect from api.db import db_client from api.db.models import OrganizationConfigurationModel, UserModel @@ -563,9 +564,15 @@ async def websocket_endpoint( websocket, workflow_id, user_id, workflow_run_id ) + except WebSocketDisconnect as e: + logger.info(f"WebSocket disconnected: code={e.code}, reason={e.reason}") except Exception as e: logger.error(f"Error in WebSocket connection: {e}") - await websocket.close(1011, "Internal server error") + try: + await websocket.close(1011, "Internal server error") + except RuntimeError: + # WebSocket already closed, ignore + pass @router.post("/twilio/status-callback/{workflow_run_id}") diff --git a/api/services/configuration/registry.py b/api/services/configuration/registry.py index f2c2a2b..5f9d043 100644 --- a/api/services/configuration/registry.py +++ b/api/services/configuration/registry.py @@ -263,13 +263,13 @@ SARVAM_LANGUAGES = [ ] -# @register_tts -# class SarvamTTSConfiguration(BaseTTSConfiguration): -# provider: Literal[ServiceProviders.SARVAM] = ServiceProviders.SARVAM -# model: str = Field(default="bulbul:v2", json_schema_extra={"examples": SARVAM_TTS_MODELS}) -# voice: str = Field(default="anushka", json_schema_extra={"examples": SARVAM_VOICES}) -# language: str = Field(default="hi-IN", json_schema_extra={"examples": SARVAM_LANGUAGES}) -# api_key: str +@register_tts +class SarvamTTSConfiguration(BaseTTSConfiguration): + provider: Literal[ServiceProviders.SARVAM] = ServiceProviders.SARVAM + model: str = Field(default="bulbul:v2", json_schema_extra={"examples": SARVAM_TTS_MODELS}) + voice: str = Field(default="anushka", json_schema_extra={"examples": SARVAM_VOICES}) + language: str = Field(default="hi-IN", json_schema_extra={"examples": SARVAM_LANGUAGES}) + api_key: str TTSConfig = Annotated[ @@ -278,7 +278,7 @@ TTSConfig = Annotated[ OpenAITTSService, ElevenlabsTTSConfiguration, DograhTTSService, - # SarvamTTSConfiguration, + SarvamTTSConfiguration, ], Field(discriminator="provider"), ] @@ -369,12 +369,12 @@ class DograhSTTService(BaseSTTConfiguration): SARVAM_STT_MODELS = ["saarika:v2.5", "saaras:v2"] -# @register_stt -# class SarvamSTTConfiguration(BaseSTTConfiguration): -# provider: Literal[ServiceProviders.SARVAM] = ServiceProviders.SARVAM -# model: str = Field(default="saarika:v2.5", json_schema_extra={"examples": SARVAM_STT_MODELS}) -# language: str = Field(default="hi-IN", json_schema_extra={"examples": SARVAM_LANGUAGES}) -# api_key: str +@register_stt +class SarvamSTTConfiguration(BaseSTTConfiguration): + provider: Literal[ServiceProviders.SARVAM] = ServiceProviders.SARVAM + model: str = Field(default="saarika:v2.5", json_schema_extra={"examples": SARVAM_STT_MODELS}) + language: str = Field(default="hi-IN", json_schema_extra={"examples": SARVAM_LANGUAGES}) + api_key: str # Speechmatics STT Service @@ -423,7 +423,7 @@ STTConfig = Annotated[ OpenAISTTConfiguration, DograhSTTService, SpeechmaticsSTTConfiguration, - # SarvamSTTConfiguration, + SarvamSTTConfiguration, ], Field(discriminator="provider"), ] diff --git a/pipecat b/pipecat index dffa63e..a1d3062 160000 --- a/pipecat +++ b/pipecat @@ -1 +1 @@ -Subproject commit dffa63e802834b6c10403522ef7b06400f5bf027 +Subproject commit a1d3062446240b6b27ebc787d28578e4561e7441