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

Stream parser against JSON schema #7879

Closed
3 of 13 tasks
wellhowtosay opened this issue Oct 20, 2023 · 3 comments
Closed
3 of 13 tasks

Stream parser against JSON schema #7879

wellhowtosay opened this issue Oct 20, 2023 · 3 comments

Comments

@wellhowtosay
Copy link

Initial Checks

  • I have searched Google & GitHub for similar requests and couldn't find anything
  • I have read and followed the docs and still think this feature is missing

Description

LLM plugin Frameworks like Langchain require model to genearte a function call which is basically a json string, include fields like function_name, params, so that LLMs can extent their abilities to real world applications. However, LLMs generate the json string without any constraint related to the json schema of function definition, which cases some challenges to this LLM plugin idea. for example , LLMs may call a function that doesn't exist !
Projects like clownfish provides a stream json parser which can constrain LLMs to follow given JSON schema during generating the JSON string. However this project only supports very few features in pydantic and I deeply doubt it's perfermance. And I do believe you are the best to provide with this feature! I do believe this can be a great contribution to LLM community.

Affected Components

@sydney-runkle
Copy link
Member

@samuelcolvin has implemented this in pydantic-core, and this should be released with 2.7, our upcoming minor release 🚀. Thus, marking this as closed :).

@samuelcolvin
Copy link
Member

I think this is fixed in pydantic/pydantic-core#1240 - once we've done a pydantic-core release, you'll be able to do

import pydantic_core

print(pydantic_core.from_json('{"a": 1, "b": 2, "c', allow_partial=True))
#> {'a': 1, 'b': 2}

@wellhowtosay
Copy link
Author

wellhowtosay commented Mar 28, 2024

thanks you guys are amazing !

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

No branches or pull requests

3 participants