Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zod parsing error on DONE token #36

Open
jbergs-dsit opened this issue Oct 13, 2024 · 3 comments
Open

Zod parsing error on DONE token #36

jbergs-dsit opened this issue Oct 13, 2024 · 3 comments

Comments

@jbergs-dsit
Copy link

It seems that Zod struggles to parse API responses at times.

Unexpected token 'D', \"[DONE]\" is not valid JSON",
I've only stumbled across this in our server logs and have not been able to properly reproduce this error.

Has anyone else come across this?


client

      const mistral = new Mistral({ apiKey: apiKey, serverURL: customBaseURL });

      const result = await mistral.chat.stream({
        model,
        messages: messages as MistralMessage[],
        maxTokens,
      });

error

 {
    "code": "custom",
    "message": "malformed json: SyntaxError: Unexpected token 'D', \"[DONE]\" is not valid JSON",
    "path": [
      "data"
    ]
  }
]
ZodError: [
  {
    "code": "custom",
    "message": "malformed json: SyntaxError: Unexpected token 'D', \"[DONE]\" is not valid JSON",
    "path": [
      "data"
    ]
  }
]
    at get error [as error] (/usr/src/app/apps/someApp/dist/index.js:36801:27)
    at _ZodObject.parse (/usr/src/app/apps/someApp/dist/index.js:36905:22)
    at decoder (/usr/src/app/apps/someApp/dist/index.js:48267:27)
    at parseEvent (/usr/src/app/apps/someApp/dist/index.js:41444:14)
    at [Symbol.asyncIterator] (/usr/src/app/apps/someApp/dist/index.js:41341:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.start (/usr/src/app/apps/someApp/dist/index.js:56920:26)
@GaspardBT
Copy link
Collaborator

Hey thanks for reporting the issue.
Could you provide more info, if possible:

  • model name
  • queries samples
  • time window
    So we can look if it correlate with a specific change in our API (if you want to not release those info publicly you can go through our platform help center here)

@jbergs-dsit
Copy link
Author

we're using Large 2507 deployed on Azure.
I see in your docs that streams are expected to send back data: 'DONE' completion events [here] but again in CompletionResponse that doesn't seem to be accounted for [here]

@jbergs-dsit
Copy link
Author

jbergs-dsit commented Nov 27, 2024

Maybe could there at least be some callback handlers added in the code e.g. onError etc so we can handle the ZOD error the code throws a bit better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants