-
-
Notifications
You must be signed in to change notification settings - Fork 720
Propagate schema through the chain #1297
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
Open
andrewsanchez
wants to merge
4
commits into
simonw:main
Choose a base branch
from
AnkiHubSoftware:fix-1222-tools-with-schemas-bug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Propagate schema through the chain #1297
andrewsanchez
wants to merge
4
commits into
simonw:main
from
AnkiHubSoftware:fix-1222-tools-with-schemas-bug
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7f3d650 to
f1ce873
Compare
Owner
|
Manually tested like this: |
Owner
|
And in |
Owner
|
(This is a really good PR, docs + tests look great.) |
Owner
|
Also tested the Python API like this: import llm
from llm.tools import llm_time
from llm.utils import schema_dsl
response = llm.get_model().conversation().chain(
"What is the time?",
tools=[llm_time],
schema=schema_dsl("date: current date")
)
print(response.text()) |
Owner
|
Those test failures can be fixed by running: uv run black .
uv run cog -r -p "import sys, os; sys._called_from_test=True; os.environ['LLM_USER_PATH'] = '/tmp'" docs/**/*.md docs/*.md README.mdOr do |
Author
|
Cool, done in e64f8fe, @simonw! just fix output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is intended to close:
However, I think this raises some questions regarding the correct/expected behavior, so I'm a bit stuck regarding how to test this.
Here is my understanding of the correct behavior: If both a schema and a tool(s) are provided, we will always have a chain of
When a structured output is desired, I have the following assumptions about the correct behavior:
The initial LLM call
The expected response is one or more tool calls, not a structured output (this is expected in a subsequent response after we send the tool call results back to the LLM). Therefore, I wonder should the schema be excluded from this initial request?
Even if we do include the schema in all requests, I think it will work just fine. At least, that is what I have observed so far with gpt-5. However, for explicit clarity, I wonder if it would be better not to send the schema with the first request.
Here are two examples to illustrate.
Send the schema with the initial and subsequent requests
Details
Exclude the schema from the initial requests
Details
As you can see, the final result is nearly the same. But if we include the schema in the first call, we are trusting the LLM to make the right decision: ignore the schema and simply respond with a tool call.