Makes composer portable#29
Open
jtoman wants to merge 8 commits into
Open
Conversation
IN THEORY
* Despite the types of `content`, `list[str | dict]` can't be used for content blocks on openai, just `str | list[dict]`, use graphcore util * Use "normalized" usage metadata, provide accurate pricing * ignore "tool_call" and "function_call" content blocks; pull from aimessage.tool_calls (oops) * fix reasoning format * switch to stateless reasoning API
Contributor
Author
|
Other big changes while reading this:
|
shellygr
reviewed
Jul 1, 2026
shellygr
left a comment
Contributor
There was a problem hiding this comment.
2 nits and then ready to approve
Comment on lines
+165
to
+167
| temperature=1, | ||
| timeout=None, | ||
| max_retries=8, |
Contributor
There was a problem hiding this comment.
- do we want to make any of these configurable?
- is it okay timeout isn't set?
Contributor
Author
There was a problem hiding this comment.
they're hardcoded currently. I think when we've set timeout in the past anthropic's API flakiness has bit us.
|
|
||
| # Pricing tables transcribed from Anthropic + OpenAI rate cards. | ||
| # Sources should be re-checked when new model families ship. | ||
| _PRICING: list[tuple[str, _ModelPricing]] = [ |
Contributor
There was a problem hiding this comment.
are we sure it's the only place in the code where we hold pricing information?
Contributor
Author
There was a problem hiding this comment.
UH, I don't know any other place in the AP code, there might be something in AS I'm not aware of
shellygr
approved these changes
Jul 3, 2026
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
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.
Abstract over the backend model provider via the new
composer.llmmodule. The actual BaseChatModel construction is handled via theModelProvidertype, which also carries the provider kind. There is a bunch of wiring, dispatch, and feature detection login in this module.The bigger change in this PR actually comes from the memory tool and the tool display.
First, we previously scraped anthropic's (custom) tool call content blocks (openai calls them "function calls") which completely broke display when using chatgpt. We instead use the (standardized)
tool_callsproperty that LC provides for us.Next, the memory tool we were sending to Claude was a custom name that claude was fine tuned on. OpenAI had no idea what to do with this custom tool name, and the schema that Claude used was actually pretty awful to formalize as a schema. Accordingly, we changed graphcore to export a "real" memory tool, and then have the memory backend generator returned by standard connections handle the choice of the right tool from graphcore.
One final wrinkle: the
contenttype of the LC's Messages isstr | list[str | dict]but this is a lie; openai does not allow you to have plain strings in a list, only dicts. SO we reintroduce our good friendsainvokeandinvokein graphcore, and use those to normalize around this problem.The rest of the changes in this PR are just changing the plumbing of services to no longer assume "always anthropic".