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

handling of markdown json #10

Open
flazouh opened this issue Nov 20, 2024 · 3 comments
Open

handling of markdown json #10

flazouh opened this issue Nov 20, 2024 · 3 comments

Comments

@flazouh
Copy link

flazouh commented Nov 20, 2024

sometimes openai returns ```json { "key": "value" } ``` does this lib handles this use case ?

@CNSeniorious000
Copy link
Member

CNSeniorious000 commented Nov 20, 2024

Nope. But there are two workarounds:

  • Use json mode.
  • Detect JSON boundary using regex like
    ```json\n(.+?)(?:\n```|`{0,3}\Z)

@flazouh
Copy link
Author

flazouh commented Nov 20, 2024

ok thanks you, nice lib btw. was gonna implement it myself and thought someone must have had the idea already

@yar2001
Copy link

yar2001 commented Dec 12, 2024

You can find the first { symbol and the last } in the response. If } is not found or does not match {, then you can determine that the JSON is partial and can be handled by this library.

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

3 participants