kimi-vercel-ai-sdk-provider 0.2.0 → 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/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ var kimiErrorSchema = z.union([
31
31
  error: z.object({
32
32
  message: z.string(),
33
33
  type: z.string().nullish(),
34
- param: z.any().nullish(),
34
+ param: z.string().nullish(),
35
35
  code: z.union([z.string(), z.number()]).nullish(),
36
36
  request_id: z.string().nullish()
37
37
  })
@@ -260,24 +260,25 @@ function isBuiltinToolName(toolName) {
260
260
  }
261
261
  var kimiTools = {
262
262
  /**
263
- * Create a web search tool for use with Kimi models.
264
- *
265
- * @param config - Optional configuration
266
- * @returns A provider tool definition
267
- *
268
- * @example
269
- * ```ts
270
- * import { kimi, kimiTools } from 'ai-sdk-provider-kimi';
271
- *
272
- * const result = await generateText({
273
- * model: kimi('kimi-k2.5'),
274
- * tools: {
275
- * webSearch: kimiTools.webSearch(),
276
- * },
277
- * prompt: 'What are the latest AI news?',
278
- * });
279
- * ```
280
- */
263
+ * Create a web search tool for use with Kimi models.
264
+ *
265
+ * @param config - Optional configuration
266
+ * @returns A provider tool definition
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * import { kimi, kimiTools } from 'kimi-vercel-ai-sdk-provider
271
+ ';
272
+ *
273
+ * const result = await generateText({
274
+ * model: kimi('kimi-k2.5'),
275
+ * tools: {
276
+ * webSearch: kimiTools.webSearch(),
277
+ * },
278
+ * prompt: 'What are the latest AI news?',
279
+ * });
280
+ * ```
281
+ */
281
282
  webSearch: (config) => {
282
283
  return {
283
284
  type: "provider",
@@ -286,24 +287,25 @@ var kimiTools = {
286
287
  };
287
288
  },
288
289
  /**
289
- * Create a code interpreter tool for use with Kimi models.
290
- *
291
- * @param config - Optional configuration
292
- * @returns A provider tool definition
293
- *
294
- * @example
295
- * ```ts
296
- * import { kimi, kimiTools } from 'ai-sdk-provider-kimi';
297
- *
298
- * const result = await generateText({
299
- * model: kimi('kimi-k2.5'),
300
- * tools: {
301
- * codeInterpreter: kimiTools.codeInterpreter(),
302
- * },
303
- * prompt: 'Calculate the factorial of 10',
304
- * });
305
- * ```
306
- */
290
+ * Create a code interpreter tool for use with Kimi models.
291
+ *
292
+ * @param config - Optional configuration
293
+ * @returns A provider tool definition
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * import { kimi, kimiTools } from 'kimi-vercel-ai-sdk-provider
298
+ ';
299
+ *
300
+ * const result = await generateText({
301
+ * model: kimi('kimi-k2.5'),
302
+ * tools: {
303
+ * codeInterpreter: kimiTools.codeInterpreter(),
304
+ * },
305
+ * prompt: 'Calculate the factorial of 10',
306
+ * });
307
+ * ```
308
+ */
307
309
  codeInterpreter: (config) => {
308
310
  return {
309
311
  type: "provider",
@@ -1251,6 +1253,21 @@ var kimiTokenUsageSchema = z3.object({
1251
1253
  reasoning_tokens: z3.number().nullish()
1252
1254
  }).nullish()
1253
1255
  }).nullish();
1256
+ var kimiContentPartSchema = z3.union([
1257
+ z3.object({
1258
+ type: z3.literal("text"),
1259
+ text: z3.string()
1260
+ }),
1261
+ z3.object({
1262
+ type: z3.literal("image_url"),
1263
+ image_url: z3.object({
1264
+ url: z3.string()
1265
+ })
1266
+ }),
1267
+ z3.looseObject({
1268
+ type: z3.string()
1269
+ })
1270
+ ]);
1254
1271
  var kimiChatResponseSchema = z3.looseObject({
1255
1272
  id: z3.string().nullish(),
1256
1273
  created: z3.number().nullish(),
@@ -1259,7 +1276,7 @@ var kimiChatResponseSchema = z3.looseObject({
1259
1276
  z3.object({
1260
1277
  message: z3.object({
1261
1278
  role: z3.string().nullish(),
1262
- content: z3.union([z3.string(), z3.array(z3.any())]).nullish(),
1279
+ content: z3.union([z3.string(), z3.array(kimiContentPartSchema)]).nullish(),
1263
1280
  reasoning_content: z3.string().nullish(),
1264
1281
  reasoning: z3.string().nullish(),
1265
1282
  tool_calls: z3.array(
@@ -1776,7 +1793,7 @@ function guessFilename(attachment, contentType) {
1776
1793
  const urlPath = attachment.url.split("?")[0];
1777
1794
  const segments = urlPath.split("/");
1778
1795
  const lastSegment = segments[segments.length - 1];
1779
- if (lastSegment && lastSegment.includes(".")) {
1796
+ if (lastSegment.includes(".")) {
1780
1797
  return lastSegment;
1781
1798
  }
1782
1799
  }
@@ -1792,7 +1809,7 @@ function guessFilename(attachment, contentType) {
1792
1809
  }
1793
1810
 
1794
1811
  // src/version.ts
1795
- var VERSION = "0.2.0".length > 0 ? "0.2.0" : "0.0.0";
1812
+ var VERSION = "0.3.0".length > 0 ? "0.3.0" : "0.0.0";
1796
1813
 
1797
1814
  // src/kimi-provider.ts
1798
1815
  var GLOBAL_BASE_URL = "https://api.moonshot.ai/v1";