Skip to content

Sarvam ai integration#129

Merged
Sandeep-BA merged 11 commits intomainfrom
sarvam-ai
Feb 24, 2026
Merged

Sarvam ai integration#129
Sandeep-BA merged 11 commits intomainfrom
sarvam-ai

Conversation

@Sandeep-BA
Copy link
Collaborator

No description provided.

Sandeep-BA and others added 11 commits February 11, 2026 16:35
- Fix critical bugs: wrong auth header (Bearer → api-subscription-key),
  wrong endpoint (/chat/completions → /v1/chat/completions), broken SSE
  streaming (message → delta), missing stream flag in request body
- Restructure as single-module contrib/sarvam-ai with Builder pattern
  matching Gemini architecture
- Add SarvamAiConfig with full API parameter support (temperature, topP,
  reasoningEffort, wikiGrounding, frequencyPenalty, presencePenalty)
- Add SarvamAiLlmConnection for multi-turn streaming chat sessions
- Add SarvamSttService with REST + WebSocket streaming STT (saaras:v3)
- Add SarvamTtsService with REST + WebSocket streaming TTS (bulbul:v3)
- Add SarvamVisionService for Document Intelligence (async job pipeline)
- Add SarvamRetryInterceptor with exponential backoff + jitter
- Add SarvamAiException with structured error fields
- Add proper chat domain models (ChatRequest, ChatResponse, ChatChoice,
  ChatMessage, ChatUsage) handling both message and delta formats
- Remove duplicate Sarvam code from core module
- Add 35 unit tests covering all services

Co-authored-by: Cursor <cursoragent@cursor.com>
Implements BaseLlm for Sarvam AI's OpenAI-compatible chat completions
API with support for both streaming (SSE) and non-streaming modes,
tool/function calling, and token usage tracking.

Configurable via SARVAM_API_BASE and SARVAM_API_KEY env vars.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add connect/read timeouts (30s/120s) to prevent hanging connections
- Add stream_options.include_usage for token tracking in streaming
- Fix function call history: serialize assistant tool_calls as proper
  OpenAI tool_calls array instead of plain text
- Forward max_tokens from GenerateContentConfig
- Extract shared HTTP connection setup into openConnection()
- Make ObjectMapper a static singleton instead of per-tool allocation
- Extract streaming finalization into emitFinalStreamResponse()
- Log and surface error responses from non-streaming calls
- Add proper instanceof checks in normalizeTypeStrings

Co-authored-by: Cursor <cursoragent@cursor.com>
- 10 unit tests covering openAiMessageToParts (text, null, tool calls,
  empty args, priority, fallback), constructor, and connect()
- Warn at construction time if SARVAM_API_KEY env var is missing

Co-authored-by: Cursor <cursoragent@cursor.com>
Covers Chat (LLM), STT, TTS, Vision, Live Connections, retry logic,
configuration, authentication, test coverage, and RAE integration.

Co-authored-by: Cursor <cursoragent@cursor.com>
Tags added to 23 files across contrib/sarvam-ai (main + test) and
core SarvamBaseLM/SarvamBaseLMTest.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sandeep-BA Sandeep-BA merged commit 43ea5a4 into main Feb 24, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant