Conversation
|
Nice fix, and thanks for citing tidyverse/ellmer#1101 — that made it much faster to compare approaches here. One thing I want to flag before merging: the two providers fix this in different ways, and I think that's worth closing before it ships.
ellmer doesn't have this asymmetry because I think chatlas should have that same symmetry. Concretely: pull @staticmethod
def _as_input_param(content: "Content", role: "Role") -> "ResponseInputItemParam":
content = bedrock_materialize_url(content)
return OpenAIProvider._as_input_param(content, role)instead of the I tried this out against your branch to check it's a real equivalence, not just a smaller diff:
Happy to open this as a follow-up/alternative branch if useful rather than asking you to rework it — mostly wanted to raise the asymmetry before it lands, since the next |
Closes #410.
Since #345,
content_pdf_url()andcontent_document_url()pass the URL through to the provider. The two mantle providers inherit that fromAnthropicProviderandOpenAIProvider, but bedrock-mantle can't fetch URLs, so those requests fail with a 400.BedrockMessagesProviderandBedrockResponsesProvidernow swap URL content for a copy with the bytes filled in (viaensure_bytes()) before handing it to the parent class, which then takes the base64 path. On the messages side onlyContentPDFneeded this, sinceAnthropicProvideralready downloadsContentDocument. This follows the same approach as tidyverse/ellmer#1101.Remote images have the same problem on mantle, but that predates #345, so I've left it out here.
The new tests mock the download, so they don't hit the network. I don't have Bedrock access, so this hasn't been run against a live endpoint.