mistralai / client-ts

TS Client library for Mistral AI platform
Apache License 2.0
25 stars 9 forks source link

Zod validation errors when using streaming with functions/tools #13

Closed jpaquim closed 2 months ago

jpaquim commented 2 months ago

Started getting this error after the upgrade (after fixing any breaking changes I could identify):

ZodError: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "null",
    "path": [
      "data",
      "choices",
      0,
      "delta",
      "content"
    ],
    "message": "Expected string, received null"
  },
  {
    "code": "invalid_literal",
    "expected": "function",
    "path": [
      "data",
      "choices",
      0,
      "delta",
      "tool_calls",
      0,
      "type"
    ],
    "message": "Invalid literal value, expected \"function\""
  }
]
    at get error [as error] (<dir>/node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/types.js:55:31)
    at ZodObject.parse (<dir>/node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/types.js:160:22)
    at decoder (<dir>/node_modules/.pnpm/@mistralai+mistralai@1.0.2_zod@3.23.8/node_modules/@mistralai/mistralai/funcs/chatStream.js:96:31)
    at parseEvent (<dir>/node_modules/.pnpm/@mistralai+mistralai@1.0.2_zod@3.23.8/node_modules/@mistralai/mistralai/lib/event-streams.js:149:12)
    at [Symbol.asyncIterator] (<dir>/node_modules/.pnpm/@mistralai+mistralai@1.0.2_zod@3.23.8/node_modules/@mistralai/mistralai/lib/event-streams.js:42:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.start (<dir>/src/lib/server/streams.ts:13:28)
GaspardBT commented 2 months ago

Thank you for testing and reporting this issue. This PR https://github.com/mistralai/client-ts/pull/15 will address the issue "message": "Invalid literal value, expected \"function\"", the other one will be address by https://github.com/mistralai/client-ts/pull/16

jpaquim commented 2 months ago

Thank you @GaspardBT 👍 do you happen to have an estimate for when these changes will be published to npm?

GaspardBT commented 2 months ago

It will be once this PR is merged 👍 (soon hopefully)