sarvam-ai-sdk 0.2.0-beta → 0.3.0
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 +11 -38
- package/dist/{index.mjs → index.cjs} +320 -362
- package/dist/{index.d.mts → index.d.cts} +92 -177
- package/dist/index.d.ts +91 -176
- package/dist/index.js +293 -389
- package/package.json +16 -13
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
<a href="https://github.com/rajatsandeepsen/sarvam-ai-sdk">
|
|
2
|
+
<img alt="cover" src="https://github.com/rajatsandeepsen/sarvam-ai-sdk/blob/master/cover.png?raw=true" />
|
|
3
|
+
</a>
|
|
4
|
+
|
|
1
5
|
# AI SDK - Sarvam Provider
|
|
2
6
|
|
|
3
|
-
The **[Sarvam provider](https://
|
|
7
|
+
The **[Sarvam provider](https://v6.ai-sdk.dev/providers/community-providers/sarvam)** for the [AI SDK](https://v6.ai-sdk.dev/docs)
|
|
4
8
|
contains language model support for the Sarvam chat completion, Text-to-Speech and Speech-to-Text APIs.
|
|
5
9
|
|
|
6
10
|
## Setup
|
|
@@ -8,11 +12,11 @@ contains language model support for the Sarvam chat completion, Text-to-Speech a
|
|
|
8
12
|
The **[Sarvam](http://sarvam.ai)** provider is available in the `sarvam-ai-sdk` module. You can install it with
|
|
9
13
|
|
|
10
14
|
```bash
|
|
11
|
-
npm i sarvam-ai-sdk ai@
|
|
15
|
+
npm i sarvam-ai-sdk ai@6
|
|
12
16
|
```
|
|
13
17
|
|
|
14
18
|
> [!WARNING]
|
|
15
|
-
> This package only works with Vercel AI-SDK
|
|
19
|
+
> This package only works with Vercel AI-SDK v6, not v7. Make sure to install `ai@6` in your project.
|
|
16
20
|
|
|
17
21
|
## Provider Instance
|
|
18
22
|
|
|
@@ -64,19 +68,6 @@ import { sarvam } from "sarvam-ai-sdk";
|
|
|
64
68
|
import { experimental_transcribe as transcribe } from "ai";
|
|
65
69
|
import { readFile } from "fs/promises";
|
|
66
70
|
|
|
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
71
|
const { text } = await transcribe({
|
|
81
72
|
model: sarvam.transcription("saaras:v3", "en-IN"),
|
|
82
73
|
audio: await readFile("./src/transcript-test.wav"),
|
|
@@ -85,24 +76,9 @@ const { text } = await transcribe({
|
|
|
85
76
|
console.log(text); // Pachakam thudaroo, suhruthukkale.
|
|
86
77
|
```
|
|
87
78
|
|
|
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
79
|
## Translation
|
|
104
80
|
|
|
105
|
-
> NB: Only
|
|
81
|
+
> NB: Only translates `prompt` and `role:user` messages, not `role:system` not `role:assistant`.
|
|
106
82
|
|
|
107
83
|
```ts
|
|
108
84
|
import { sarvam } from "sarvam-ai-sdk";
|
|
@@ -228,14 +204,11 @@ sarvam.languageIdentification();
|
|
|
228
204
|
// Text-to-Speech
|
|
229
205
|
sarvam.speech("bulbul:v3", "ml-IN");
|
|
230
206
|
|
|
231
|
-
// Speech-to-Text
|
|
232
|
-
sarvam.transcription("
|
|
233
|
-
|
|
234
|
-
// Speech-to-Text + Translate to English
|
|
235
|
-
sarvam.speechTranslation("saaras:v3");
|
|
207
|
+
// Speech-to-Text
|
|
208
|
+
sarvam.transcription("saaras:v3");
|
|
236
209
|
```
|
|
237
210
|
|
|
238
211
|
|
|
239
212
|
## Documentation
|
|
240
213
|
|
|
241
|
-
Please check out the **[Sarvam provider documentation](https://
|
|
214
|
+
Please check out the **[Sarvam provider documentation](https://v6.ai-sdk.dev/providers/community-providers/sarvam)** and **[Sarvam API documentation](https://docs.sarvam.ai)** for more information.
|