Specify method
for with_structured_output
#39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default option of "function_calling" for Ollama was leading to errors. Defaulting to "json_schema" (as ChatOpenAI already does) results in success for Ollama. Expose the
method
argument to the user for finer-grained control if needed.Fixes #38.
I'm not sure if this is the right approach but figured it would be a good starting point for a discussion. The script below used to trigger the parsing error mentioned in the issue. With the fix here, Ollama is able to produce Nodes and Relationships:
Output:
GraphDocument(nodes=[Node(id='Lazy Dog', type='Person', properties={}), Node(id='Red Ball', type='Object', properties={}), Node(id='Bob The Clown', type='Person', properties={})], relationships=[Relationship(source=Node(id='Lazy Dog', type='Person', properties={}), target=Node(id='Red Ball', type='Object', properties={}), type='WATCHED', properties={}), Relationship(source=Node(id='Bob The Clown', type='Person', properties={}), target=Node(id='Missles', type='Object', properties={}), type='SCARED', properties={})], source=Document(metadata={}, page_content='The lazy dog watched as the red ball rolled. Bob the clown scared the missles.'))]