sarvam-ai-sdk 0.1.4 → 0.2.0-beta

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # AI SDK - Sarvam Provider
2
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)
3
+ The **[Sarvam provider](https://v5.ai-sdk.dev/providers/ai-sdk-providers/sarvam)** for the [AI SDK](https://v5.ai-sdk.dev/docs)
4
4
  contains language model support for the Sarvam chat completion, Text-to-Speech and Speech-to-Text APIs.
5
5
 
6
6
  ## Setup
@@ -8,11 +8,11 @@ contains language model support for the Sarvam chat completion, Text-to-Speech a
8
8
  The **[Sarvam](http://sarvam.ai)** provider is available in the `sarvam-ai-sdk` module. You can install it with
9
9
 
10
10
  ```bash
11
- npm i sarvam-ai-sdk
11
+ npm i sarvam-ai-sdk ai@5
12
12
  ```
13
13
 
14
14
  > [!WARNING]
15
- > This package only works with Vercel AI-SDK v4, not latest v6. Make sure to install `ai@4` in your project.
15
+ > This package only works with Vercel AI-SDK v5, not v6 or latest v7. Make sure to install `ai@5` in your project.
16
16
 
17
17
  ## Provider Instance
18
18
 
@@ -102,14 +102,14 @@ console.log(result.text); // Cooking continues, my friends
102
102
 
103
103
  ## Translation
104
104
 
105
- > NB: Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
105
+ > NB: Only transliterates `prompt` and `role:user` messages, not `role:system` not `role:assistant`.
106
106
 
107
107
  ```ts
108
108
  import { sarvam } from "sarvam-ai-sdk";
109
109
  import { generateText } from "ai";
110
110
 
111
111
  const result = await generateText({
112
- model: sarvam.translation({
112
+ model: sarvam.translation("mayura:v1", {
113
113
  "from": "ml-IN",
114
114
  "to": "en-IN",
115
115
  }),
@@ -121,7 +121,7 @@ console.log(result.text); // Shouldn't we be careful about this, Ambane?
121
121
 
122
122
  ## Transliterate
123
123
 
124
- > NB: Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
124
+ > NB: Only transliterates `prompt` and `role:user` messages, not `role:system` not `role:assistant`.
125
125
 
126
126
  ```ts
127
127
  import { sarvam } from "sarvam-ai-sdk";
@@ -129,8 +129,8 @@ import { generateText } from "ai";
129
129
 
130
130
  const result = await generateText({
131
131
  model: sarvam.transliterate({
132
- from: "en-IN",
133
132
  to: "ml-IN",
133
+ from: "en-IN", // optional
134
134
  }),
135
135
  prompt: "eda mone, happy alle?",
136
136
  });
@@ -140,7 +140,7 @@ console.log(result.text); // എടാ മോനെ, ഹാപ്പി അല
140
140
 
141
141
  ## Language Identification
142
142
 
143
- > NB: Only identifies `prompt` and `role:user` messages, not `system` not `assistant`.
143
+ > NB: Only identifies `prompt` and `role:user` messages, not `role:system` not `role:assistant`.
144
144
 
145
145
  ```ts
146
146
  import { sarvam } from "sarvam-ai-sdk";
@@ -167,8 +167,8 @@ const result = await generateText({
167
167
  tools: {
168
168
  weather: tool({
169
169
  description: "Get the weather in a location",
170
- parameters: z.object({
171
- location: z.string().describe("The location to get the weather for"),
170
+ inputSchema: z.object({
171
+ location: z.string(),
172
172
  }),
173
173
  execute: async ({ location }) => ({
174
174
  location,
@@ -183,9 +183,6 @@ const result = await generateText({
183
183
  console.log(result.toolResults);
184
184
  ```
185
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
186
  ## Generate JSON object
190
187
 
191
188
  ```ts
@@ -195,6 +192,8 @@ import { generateObject } from 'ai';
195
192
 
196
193
  const { object } = await generateObject({
197
194
  model: sarvam("sarvam-30b"),
195
+ schemaName: "Recipe",
196
+ schemaDescription: "A recipe with a name, ingredients and steps",
198
197
  schema: z.object({
199
198
  recipe: z.object({
200
199
  name: z.string(),
@@ -208,9 +207,6 @@ const { object } = await generateObject({
208
207
  console.log(object);
209
208
  ```
210
209
 
211
- > [!WARNING]
212
- > Old `sarvam-m` models isn't trained on native JSON object generation. So we recommend using latest models.
213
-
214
210
  ## All APIs
215
211
 
216
212
  ```ts
@@ -221,10 +217,10 @@ sarvam("sarvam-105b");
221
217
  sarvam.languageModel("sarvam-30b");
222
218
 
223
219
  // Text-to-Text + Transliteration
224
- sarvam.transliterate({ from: "en-IN", to: "ml-IN" });
220
+ sarvam.transliterate({ to: "ml-IN", from: "en-IN" });
225
221
 
226
222
  // Text-to-Text + Translation
227
- sarvam.translation({ from: "en-IN", to: "ml-IN" });
223
+ sarvam.translation("mayura:v1", { from: "en-IN", to: "ml-IN" });
228
224
 
229
225
  // Text-to-Text + Language identification
230
226
  sarvam.languageIdentification();
@@ -242,4 +238,4 @@ sarvam.speechTranslation("saaras:v3");
242
238
 
243
239
  ## Documentation
244
240
 
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.
241
+ Please check out the **[Sarvam provider documentation](https://v5.ai-sdk.dev/providers/ai-sdk-providers/sarvam)** and **[Sarvam API documentation](https://docs.sarvam.ai)** for more information.