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

JSON Schema #700

Open
cclark1e opened this issue Nov 18, 2024 · 2 comments
Open

JSON Schema #700

cclark1e opened this issue Nov 18, 2024 · 2 comments
Labels
question Further information is requested

Comments

@cclark1e
Copy link

Hi all,

Thank you for your excellent work on PaperQA2.

OpenAI provides an option for a JSON schema that the LLM must respond with.
(https://openai.com/index/introducing-structured-outputs-in-the-api/)

Is it possible to pass this option through paperQA2 so the final response fits within this schema?

Copy link

dosubot bot commented Nov 18, 2024

Hey @cclark1e, I'm here to help you with any questions or issues you have with PaperQA2. Let's tackle this together!

I couldn't find a direct configuration option in PaperQA2 to specify a JSON schema for the output format. However, there is a reference in the paperqa/docs.py file indicating an intention to specify a JSON schema when many LLM providers support it. The code attempts to parse JSON from a response, which suggests some level of handling for structured outputs [1].

Additionally, there is a test case in the tests/test_paperqa.py file that demonstrates the use of a JSON schema for structuring outputs. This test uses a JSON format to provide a summary, author name, and relevance score [2].

For more detailed implementation or customization, you might need to modify the code to integrate OpenAI's structured output feature directly.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the question Further information is requested label Nov 18, 2024
@jamesbraza
Copy link
Collaborator

Hello @cclark1e when you say "final response", what do you mean? Like the string AnswerResponse.session.answer
or formatted_answer follows a certain schema?

Can you give an example schema for what you're thinking?

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

No branches or pull requests

2 participants