Skip to content

Makes composer portable#29

Open
jtoman wants to merge 8 commits into
masterfrom
jtoman/provider-portability
Open

Makes composer portable#29
jtoman wants to merge 8 commits into
masterfrom
jtoman/provider-portability

Conversation

@jtoman

@jtoman jtoman commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Abstract over the backend model provider via the new composer.llm module. The actual BaseChatModel construction is handled via the ModelProvider type, 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_calls property 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 content type of the LC's Messages is str | 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 friends ainvoke and invoke in 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".

jtoman added 4 commits June 29, 2026 16:18
* 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
@jtoman jtoman requested a review from shellygr June 29, 2026 23:32
@jtoman

jtoman commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Other big changes while reading this:

  • more accurate live token prices
  • changes to the file API to account for the shape of "uploaded file reference" blocks

@shellygr shellygr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 nits and then ready to approve

Comment thread composer/llm/anthropic.py
Comment on lines +165 to +167
temperature=1,
timeout=None,
max_retries=8,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. do we want to make any of these configurable?
  2. is it okay timeout isn't set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]] = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure it's the only place in the code where we hold pricing information?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UH, I don't know any other place in the AP code, there might be something in AS I'm not aware of

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants