sarvam-ai-sdk 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -219
- package/dist/index.d.mts +34 -27
- package/dist/index.d.ts +34 -27
- package/dist/index.js +89 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -143
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,219 +1,245 @@
|
|
|
1
|
-
# AI SDK - Sarvam Provider
|
|
2
|
-
|
|
3
|
-
The **[Sarvam provider](https://v4.ai-sdk.dev/providers/ai-sdk-providers/sarvam)** for the [AI SDK](https://v4.ai-sdk.dev/docs)
|
|
4
|
-
contains language model support for the Sarvam chat completion, Text-to-Speech and Speech-to-Text APIs.
|
|
5
|
-
|
|
6
|
-
## Setup
|
|
7
|
-
|
|
8
|
-
The **[Sarvam](http://sarvam.ai)** provider is available in the `sarvam-ai-sdk` module. You can install it with
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm i sarvam-ai-sdk
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
> [!WARNING]
|
|
15
|
-
> This package only works with Vercel AI-SDK v4, not latest v6. Make sure to install `ai@4` in your project.
|
|
16
|
-
|
|
17
|
-
## Provider Instance
|
|
18
|
-
|
|
19
|
-
You can import the default provider instance `sarvam` from `sarvam-ai-sdk`:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import { sarvam } from 'sarvam-ai-sdk';
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Create `.env` file with API key from **[Sarvam Dashboard](https://dashboard.sarvam.ai/)**
|
|
26
|
-
```bash
|
|
27
|
-
SARVAM_API_KEY="your_api_key"
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Example
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
import { sarvam } from 'sarvam-ai-sdk';
|
|
34
|
-
import { generateText } from 'ai';
|
|
35
|
-
|
|
36
|
-
const { text } = await generateText({
|
|
37
|
-
model: sarvam("sarvam-30b"),
|
|
38
|
-
prompt: "Translate this to malayalam: 'Keep cooking, guys'",
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
console.log(text); // പാചകം തുടരൂ, സുഹൃത്തുക്കളേ
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Text-to-Speech
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
48
|
-
import { experimental_generateSpeech as generateSpeech } from "ai";
|
|
49
|
-
import { writeFile } from "fs/promises";
|
|
50
|
-
|
|
51
|
-
const { audio } = await generateSpeech({
|
|
52
|
-
model: sarvam.speech("bulbul:v3", "ml-IN"),
|
|
53
|
-
text: "പാചകം തുടരൂ, സുഹൃത്തുക്കളേ",
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const audioBuffer = Buffer.from(audio.base64, "base64")
|
|
57
|
-
await writeFile("./src/transcript-test.wav", audioBuffer);
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Speech-to-Text
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
64
|
-
import { experimental_transcribe as transcribe } from "ai";
|
|
65
|
-
import { readFile } from "fs/promises";
|
|
66
|
-
|
|
67
|
-
const { text } = await transcribe({
|
|
68
|
-
model: sarvam.transcription("saarika:v2.5", "ml-IN")
|
|
69
|
-
audio: await readFile("./src/transcript-test.wav"),
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
console.log(text); // പാചകം തുടരും സുഹൃത്തുക്കളെ
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
77
|
-
import { experimental_transcribe as transcribe } from "ai";
|
|
78
|
-
import { readFile } from "fs/promises";
|
|
79
|
-
|
|
80
|
-
const { text } = await transcribe({
|
|
81
|
-
model: sarvam.transcription("saaras:v3", "en-IN"),
|
|
82
|
-
audio: await readFile("./src/transcript-test.wav"),
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
console.log(text); // Pachakam thudaroo, suhruthukkale.
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Speech-to-Text-Translate
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
92
|
-
import { experimental_transcribe as transcribe } from "ai";
|
|
93
|
-
import { readFile } from "fs/promises";
|
|
94
|
-
|
|
95
|
-
const result = await transcribe({
|
|
96
|
-
model: sarvam.speechTranslation("saaras:v2.5"),
|
|
97
|
-
audio: await readFile("./src/transcript-test.wav"),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
console.log(result.text); // Cooking continues, my friends
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Translation
|
|
104
|
-
|
|
105
|
-
> NB: Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
109
|
-
import { generateText } from "ai";
|
|
110
|
-
|
|
111
|
-
const result = await generateText({
|
|
112
|
-
model: sarvam.translation({
|
|
113
|
-
"from": "ml-IN",
|
|
114
|
-
"to": "en-IN",
|
|
115
|
-
}),
|
|
116
|
-
prompt: "ഇതൊക്കെ ശ്രദ്ധിക്കണ്ടേ അംബാനെ?",
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
console.log(result.text); // Shouldn't we be careful about this, Ambane?
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Transliterate
|
|
123
|
-
|
|
124
|
-
> NB: Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
128
|
-
import { generateText } from "ai";
|
|
129
|
-
|
|
130
|
-
const result = await generateText({
|
|
131
|
-
model: sarvam.transliterate({
|
|
132
|
-
from: "en-IN",
|
|
133
|
-
to: "ml-IN",
|
|
134
|
-
}),
|
|
135
|
-
prompt: "eda mone, happy alle?",
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
console.log(result.text); // എടാ മോനെ, ഹാപ്പി അല്ലേ?
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## Language Identification
|
|
142
|
-
|
|
143
|
-
> NB: Only identifies `prompt` and `role:user` messages, not `system` not `assistant`.
|
|
144
|
-
|
|
145
|
-
```ts
|
|
146
|
-
import { sarvam } from "sarvam-ai-sdk";
|
|
147
|
-
import { generateText } from "ai";
|
|
148
|
-
|
|
149
|
-
const result = await generateText({
|
|
150
|
-
model: sarvam.languageIdentification(),
|
|
151
|
-
prompt: "ബുദ്ധിയാണ് സാറേ ഇവൻ്റെ മെയിൻ",
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
console.log(result.text); // ml-IN
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Tool Calling
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
1
|
+
# AI SDK - Sarvam Provider
|
|
2
|
+
|
|
3
|
+
The **[Sarvam provider](https://v4.ai-sdk.dev/providers/ai-sdk-providers/sarvam)** for the [AI SDK](https://v4.ai-sdk.dev/docs)
|
|
4
|
+
contains language model support for the Sarvam chat completion, Text-to-Speech and Speech-to-Text APIs.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
The **[Sarvam](http://sarvam.ai)** provider is available in the `sarvam-ai-sdk` module. You can install it with
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i sarvam-ai-sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
> [!WARNING]
|
|
15
|
+
> This package only works with Vercel AI-SDK v4, not latest v6. Make sure to install `ai@4` in your project.
|
|
16
|
+
|
|
17
|
+
## Provider Instance
|
|
18
|
+
|
|
19
|
+
You can import the default provider instance `sarvam` from `sarvam-ai-sdk`:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { sarvam } from 'sarvam-ai-sdk';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Create `.env` file with API key from **[Sarvam Dashboard](https://dashboard.sarvam.ai/)**
|
|
26
|
+
```bash
|
|
27
|
+
SARVAM_API_KEY="your_api_key"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { sarvam } from 'sarvam-ai-sdk';
|
|
34
|
+
import { generateText } from 'ai';
|
|
35
|
+
|
|
36
|
+
const { text } = await generateText({
|
|
37
|
+
model: sarvam("sarvam-30b"),
|
|
38
|
+
prompt: "Translate this to malayalam: 'Keep cooking, guys'",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(text); // പാചകം തുടരൂ, സുഹൃത്തുക്കളേ
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Text-to-Speech
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
48
|
+
import { experimental_generateSpeech as generateSpeech } from "ai";
|
|
49
|
+
import { writeFile } from "fs/promises";
|
|
50
|
+
|
|
51
|
+
const { audio } = await generateSpeech({
|
|
52
|
+
model: sarvam.speech("bulbul:v3", "ml-IN"),
|
|
53
|
+
text: "പാചകം തുടരൂ, സുഹൃത്തുക്കളേ",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const audioBuffer = Buffer.from(audio.base64, "base64")
|
|
57
|
+
await writeFile("./src/transcript-test.wav", audioBuffer);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Speech-to-Text
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
64
|
+
import { experimental_transcribe as transcribe } from "ai";
|
|
65
|
+
import { readFile } from "fs/promises";
|
|
66
|
+
|
|
67
|
+
const { text } = await transcribe({
|
|
68
|
+
model: sarvam.transcription("saarika:v2.5", "ml-IN"),
|
|
69
|
+
audio: await readFile("./src/transcript-test.wav"),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(text); // പാചകം തുടരും സുഹൃത്തുക്കളെ
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
77
|
+
import { experimental_transcribe as transcribe } from "ai";
|
|
78
|
+
import { readFile } from "fs/promises";
|
|
79
|
+
|
|
80
|
+
const { text } = await transcribe({
|
|
81
|
+
model: sarvam.transcription("saaras:v3", "en-IN"),
|
|
82
|
+
audio: await readFile("./src/transcript-test.wav"),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
console.log(text); // Pachakam thudaroo, suhruthukkale.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Speech-to-Text-Translate
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
92
|
+
import { experimental_transcribe as transcribe } from "ai";
|
|
93
|
+
import { readFile } from "fs/promises";
|
|
94
|
+
|
|
95
|
+
const result = await transcribe({
|
|
96
|
+
model: sarvam.speechTranslation("saaras:v2.5"),
|
|
97
|
+
audio: await readFile("./src/transcript-test.wav"),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log(result.text); // Cooking continues, my friends
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Translation
|
|
104
|
+
|
|
105
|
+
> NB: Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
109
|
+
import { generateText } from "ai";
|
|
110
|
+
|
|
111
|
+
const result = await generateText({
|
|
112
|
+
model: sarvam.translation({
|
|
113
|
+
"from": "ml-IN",
|
|
114
|
+
"to": "en-IN",
|
|
115
|
+
}),
|
|
116
|
+
prompt: "ഇതൊക്കെ ശ്രദ്ധിക്കണ്ടേ അംബാനെ?",
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
console.log(result.text); // Shouldn't we be careful about this, Ambane?
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Transliterate
|
|
123
|
+
|
|
124
|
+
> NB: Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
128
|
+
import { generateText } from "ai";
|
|
129
|
+
|
|
130
|
+
const result = await generateText({
|
|
131
|
+
model: sarvam.transliterate({
|
|
132
|
+
from: "en-IN",
|
|
133
|
+
to: "ml-IN",
|
|
134
|
+
}),
|
|
135
|
+
prompt: "eda mone, happy alle?",
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
console.log(result.text); // എടാ മോനെ, ഹാപ്പി അല്ലേ?
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Language Identification
|
|
142
|
+
|
|
143
|
+
> NB: Only identifies `prompt` and `role:user` messages, not `system` not `assistant`.
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
147
|
+
import { generateText } from "ai";
|
|
148
|
+
|
|
149
|
+
const result = await generateText({
|
|
150
|
+
model: sarvam.languageIdentification(),
|
|
151
|
+
prompt: "ബുദ്ധിയാണ് സാറേ ഇവൻ്റെ മെയിൻ",
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
console.log(result.text); // ml-IN
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Tool Calling
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { z } from "zod";
|
|
161
|
+
import { generateText, tool } from "ai";
|
|
162
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
const result = await generateText({
|
|
166
|
+
model: sarvam("sarvam-30b"),
|
|
167
|
+
tools: {
|
|
168
|
+
weather: tool({
|
|
169
|
+
description: "Get the weather in a location",
|
|
170
|
+
parameters: z.object({
|
|
171
|
+
location: z.string().describe("The location to get the weather for"),
|
|
172
|
+
}),
|
|
173
|
+
execute: async ({ location }) => ({
|
|
174
|
+
location,
|
|
175
|
+
temperature: 72 + Math.floor(Math.random() * 21) - 10,
|
|
176
|
+
}),
|
|
177
|
+
}),
|
|
178
|
+
},
|
|
179
|
+
system: "Your are a helpful AI",
|
|
180
|
+
prompt: "കൊച്ചിയിലെ കാലാവസ്ഥ എന്താണ്?",
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
console.log(result.toolResults);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
> [!WARNING]
|
|
187
|
+
> Old `sarvam-m` models isn't trained on native tool calling feature (aka JSON mode). So we recommend using latest models.
|
|
188
|
+
|
|
189
|
+
## Generate JSON object
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import { z } from "zod";
|
|
193
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
194
|
+
import { generateObject } from 'ai';
|
|
195
|
+
|
|
196
|
+
const { object } = await generateObject({
|
|
197
|
+
model: sarvam("sarvam-30b"),
|
|
198
|
+
schema: z.object({
|
|
199
|
+
recipe: z.object({
|
|
200
|
+
name: z.string(),
|
|
201
|
+
ingredients: z.array(z.string()),
|
|
202
|
+
steps: z.array(z.string()),
|
|
203
|
+
}),
|
|
204
|
+
}),
|
|
205
|
+
prompt: 'Generate a South Indian recipe, in Malayalam',
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
console.log(object);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
> [!WARNING]
|
|
212
|
+
> Old `sarvam-m` models isn't trained on native JSON object generation. So we recommend using latest models.
|
|
213
|
+
|
|
214
|
+
## All APIs
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import { sarvam } from "sarvam-ai-sdk";
|
|
218
|
+
|
|
219
|
+
// Text-to-Text + Chat Completion
|
|
220
|
+
sarvam("sarvam-105b");
|
|
221
|
+
sarvam.languageModel("sarvam-30b");
|
|
222
|
+
|
|
223
|
+
// Text-to-Text + Transliteration
|
|
224
|
+
sarvam.transliterate({ from: "en-IN", to: "ml-IN" });
|
|
225
|
+
|
|
226
|
+
// Text-to-Text + Translation
|
|
227
|
+
sarvam.translation({ from: "en-IN", to: "ml-IN" });
|
|
228
|
+
|
|
229
|
+
// Text-to-Text + Language identification
|
|
230
|
+
sarvam.languageIdentification();
|
|
231
|
+
|
|
232
|
+
// Text-to-Speech
|
|
233
|
+
sarvam.speech("bulbul:v3", "ml-IN");
|
|
234
|
+
|
|
235
|
+
// Speech-to-Text + Transcribe to same language
|
|
236
|
+
sarvam.transcription("saarika:v2.5");
|
|
237
|
+
|
|
238
|
+
// Speech-to-Text + Translate to English
|
|
239
|
+
sarvam.speechTranslation("saaras:v3");
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
## Documentation
|
|
244
|
+
|
|
245
|
+
Please check out the **[Sarvam provider documentation](https://v4.ai-sdk.dev/providers/ai-sdk-providers/sarvam)** and **[Sarvam API documentation](https://docs.sarvam.ai)** for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -3,34 +3,10 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @description
|
|
6
|
+
* @description Production models
|
|
7
7
|
*/
|
|
8
|
-
type SarvamChatModelId = "sarvam-30b" | "sarvam-30b-16k" | "sarvam-105b" | "sarvam-105b-32k" |
|
|
9
|
-
/**
|
|
10
|
-
* @description Legacy models
|
|
11
|
-
* @deprecated
|
|
12
|
-
*/
|
|
13
|
-
type SarvamChatLegacyModelId = "sarvam-m";
|
|
8
|
+
type SarvamChatModelId = "sarvam-30b" | "sarvam-30b-16k" | "sarvam-105b" | "sarvam-105b-32k" | (string & {});
|
|
14
9
|
interface SarvamChatSettings {
|
|
15
|
-
/**
|
|
16
|
-
* Whether to simulate artificial tool calling or JSON object generation, because Sarvam Models doen't support native Tool Calling or JSON Schmea.
|
|
17
|
-
* @default undefined
|
|
18
|
-
* @example
|
|
19
|
-
await generateText({
|
|
20
|
-
model: sarvam("sarvam-m", {
|
|
21
|
-
simulate: "tool-calling"
|
|
22
|
-
})
|
|
23
|
-
tools: {...}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
await generateObject({
|
|
27
|
-
model: sarvam("sarvam-m", {
|
|
28
|
-
simulate: "json-object"
|
|
29
|
-
})
|
|
30
|
-
schema: {...}
|
|
31
|
-
})
|
|
32
|
-
*/
|
|
33
|
-
simulate?: "tool-calling" | "json-object";
|
|
34
10
|
/**
|
|
35
11
|
* Whether to enable parallel function calling during tool use.
|
|
36
12
|
* @default true
|
|
@@ -52,7 +28,7 @@ declare const SarvamLanguageCodeSchema: z.ZodEnum<["hi-IN", "bn-IN", "kn-IN", "m
|
|
|
52
28
|
|
|
53
29
|
type SarvamSpeechModelId = "bulbul:v2" | "bulbul:v3" | (string & {});
|
|
54
30
|
type SarvamSpeechVoices = z.infer<typeof SpeakerSchema>;
|
|
55
|
-
declare const SpeakerSchema: z.
|
|
31
|
+
declare const SpeakerSchema: z.ZodEnum<["abhilash", "karun", "hitesh", "anushka", "manisha", "vidya", "arya", "shubh", "aditya", "rahul", "rohan", "amit", "dev", "ratan", "varun", "manan", "sumit", "kabir", "aayan", "ashutosh", "advait", "anand", "tarun", "sunny", "mani", "gokul", "vijay", "mohit", "rehan", "soham", "ritu", "priya", "neha", "pooja", "simran", "kavya", "ishita", "shreya", "roopa", "amelia", "sophia", "tanya", "shruti", "suhani", "kavitha", "rupali"]>;
|
|
56
32
|
/**
|
|
57
33
|
* Configuration settings for Sarvam Text-to-Speech API.
|
|
58
34
|
*
|
|
@@ -111,6 +87,37 @@ type SarvamSpeechSettings = {
|
|
|
111
87
|
* @example false (Disable preprocessing)
|
|
112
88
|
*/
|
|
113
89
|
enable_preprocessing?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Specifies the audio codec for the output audio file.
|
|
92
|
+
* Different codecs offer various compression and quality characteristics.
|
|
93
|
+
*/
|
|
94
|
+
output_audio_codec?: "mp3" | "linear16" | "mulaw" | "alaw" | "opus" | "flac" | "aac" | "wav";
|
|
95
|
+
/**
|
|
96
|
+
* Temperature controls how much randomness and expressiveness the TTS model uses while generating speech.
|
|
97
|
+
* Lower values produce more stable and consistent output,
|
|
98
|
+
* while higher values sound more expressive but may introduce artifacts or errors.
|
|
99
|
+
*
|
|
100
|
+
* Any number inbetween 0.01 - 2
|
|
101
|
+
* @default 0.6
|
|
102
|
+
*
|
|
103
|
+
* Note: This parameter is only supported for bulbul:v3. It has no effect on bulbul:v2.
|
|
104
|
+
*/
|
|
105
|
+
temperature?: number;
|
|
106
|
+
/**
|
|
107
|
+
* The ID of a pronunciation dictionary to apply during synthesis.
|
|
108
|
+
* When provided, matching words in the input text will be replaced with their custom pronunciations before generating speech.
|
|
109
|
+
*
|
|
110
|
+
* Only supported by bulbul:v3.
|
|
111
|
+
*/
|
|
112
|
+
dict_id?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Enable caching for the request. When enabled, identical requests will return cached audio instead of regenerating.
|
|
115
|
+
*
|
|
116
|
+
* @default false
|
|
117
|
+
*
|
|
118
|
+
* Currently in beta and only available for bulbul:v1 and bulbul:v2 models.
|
|
119
|
+
*/
|
|
120
|
+
enable_cached_responses?: boolean;
|
|
114
121
|
};
|
|
115
122
|
|
|
116
123
|
type SarvamTranscriptionModelId = "saaras:v3" | "saarika:v2.5" | (string & {});
|
package/dist/index.d.ts
CHANGED
|
@@ -3,34 +3,10 @@ import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @description
|
|
6
|
+
* @description Production models
|
|
7
7
|
*/
|
|
8
|
-
type SarvamChatModelId = "sarvam-30b" | "sarvam-30b-16k" | "sarvam-105b" | "sarvam-105b-32k" |
|
|
9
|
-
/**
|
|
10
|
-
* @description Legacy models
|
|
11
|
-
* @deprecated
|
|
12
|
-
*/
|
|
13
|
-
type SarvamChatLegacyModelId = "sarvam-m";
|
|
8
|
+
type SarvamChatModelId = "sarvam-30b" | "sarvam-30b-16k" | "sarvam-105b" | "sarvam-105b-32k" | (string & {});
|
|
14
9
|
interface SarvamChatSettings {
|
|
15
|
-
/**
|
|
16
|
-
* Whether to simulate artificial tool calling or JSON object generation, because Sarvam Models doen't support native Tool Calling or JSON Schmea.
|
|
17
|
-
* @default undefined
|
|
18
|
-
* @example
|
|
19
|
-
await generateText({
|
|
20
|
-
model: sarvam("sarvam-m", {
|
|
21
|
-
simulate: "tool-calling"
|
|
22
|
-
})
|
|
23
|
-
tools: {...}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
await generateObject({
|
|
27
|
-
model: sarvam("sarvam-m", {
|
|
28
|
-
simulate: "json-object"
|
|
29
|
-
})
|
|
30
|
-
schema: {...}
|
|
31
|
-
})
|
|
32
|
-
*/
|
|
33
|
-
simulate?: "tool-calling" | "json-object";
|
|
34
10
|
/**
|
|
35
11
|
* Whether to enable parallel function calling during tool use.
|
|
36
12
|
* @default true
|
|
@@ -52,7 +28,7 @@ declare const SarvamLanguageCodeSchema: z.ZodEnum<["hi-IN", "bn-IN", "kn-IN", "m
|
|
|
52
28
|
|
|
53
29
|
type SarvamSpeechModelId = "bulbul:v2" | "bulbul:v3" | (string & {});
|
|
54
30
|
type SarvamSpeechVoices = z.infer<typeof SpeakerSchema>;
|
|
55
|
-
declare const SpeakerSchema: z.
|
|
31
|
+
declare const SpeakerSchema: z.ZodEnum<["abhilash", "karun", "hitesh", "anushka", "manisha", "vidya", "arya", "shubh", "aditya", "rahul", "rohan", "amit", "dev", "ratan", "varun", "manan", "sumit", "kabir", "aayan", "ashutosh", "advait", "anand", "tarun", "sunny", "mani", "gokul", "vijay", "mohit", "rehan", "soham", "ritu", "priya", "neha", "pooja", "simran", "kavya", "ishita", "shreya", "roopa", "amelia", "sophia", "tanya", "shruti", "suhani", "kavitha", "rupali"]>;
|
|
56
32
|
/**
|
|
57
33
|
* Configuration settings for Sarvam Text-to-Speech API.
|
|
58
34
|
*
|
|
@@ -111,6 +87,37 @@ type SarvamSpeechSettings = {
|
|
|
111
87
|
* @example false (Disable preprocessing)
|
|
112
88
|
*/
|
|
113
89
|
enable_preprocessing?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Specifies the audio codec for the output audio file.
|
|
92
|
+
* Different codecs offer various compression and quality characteristics.
|
|
93
|
+
*/
|
|
94
|
+
output_audio_codec?: "mp3" | "linear16" | "mulaw" | "alaw" | "opus" | "flac" | "aac" | "wav";
|
|
95
|
+
/**
|
|
96
|
+
* Temperature controls how much randomness and expressiveness the TTS model uses while generating speech.
|
|
97
|
+
* Lower values produce more stable and consistent output,
|
|
98
|
+
* while higher values sound more expressive but may introduce artifacts or errors.
|
|
99
|
+
*
|
|
100
|
+
* Any number inbetween 0.01 - 2
|
|
101
|
+
* @default 0.6
|
|
102
|
+
*
|
|
103
|
+
* Note: This parameter is only supported for bulbul:v3. It has no effect on bulbul:v2.
|
|
104
|
+
*/
|
|
105
|
+
temperature?: number;
|
|
106
|
+
/**
|
|
107
|
+
* The ID of a pronunciation dictionary to apply during synthesis.
|
|
108
|
+
* When provided, matching words in the input text will be replaced with their custom pronunciations before generating speech.
|
|
109
|
+
*
|
|
110
|
+
* Only supported by bulbul:v3.
|
|
111
|
+
*/
|
|
112
|
+
dict_id?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Enable caching for the request. When enabled, identical requests will return cached audio instead of regenerating.
|
|
115
|
+
*
|
|
116
|
+
* @default false
|
|
117
|
+
*
|
|
118
|
+
* Currently in beta and only available for bulbul:v1 and bulbul:v2 models.
|
|
119
|
+
*/
|
|
120
|
+
enable_cached_responses?: boolean;
|
|
114
121
|
};
|
|
115
122
|
|
|
116
123
|
type SarvamTranscriptionModelId = "saaras:v3" | "saarika:v2.5" | (string & {});
|