anthropic: Use separate Content
type in requests and responses (#17163)
This PR splits the `Content` type for Anthropic into two new types: `RequestContent` and `ResponseContent`. As I was going through the Anthropic API docs it seems that there are different types of content that can be sent in requests vs what can be returned in responses. Using a separate type for each case tells the story a bit better and makes it easier to understand, IMO. Release Notes: - N/A
This commit is contained in:
parent
00eed768ce
commit
8901d926eb
2 changed files with 25 additions and 13 deletions
|
@ -304,17 +304,17 @@ impl LanguageModelRequest {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let anthropic_message_content: Vec<anthropic::Content> = message
|
||||
let anthropic_message_content: Vec<anthropic::RequestContent> = message
|
||||
.content
|
||||
.into_iter()
|
||||
.filter_map(|content| match content {
|
||||
MessageContent::Text(t) if !t.is_empty() => {
|
||||
Some(anthropic::Content::Text {
|
||||
Some(anthropic::RequestContent::Text {
|
||||
text: t,
|
||||
cache_control,
|
||||
})
|
||||
}
|
||||
MessageContent::Image(i) => Some(anthropic::Content::Image {
|
||||
MessageContent::Image(i) => Some(anthropic::RequestContent::Image {
|
||||
source: anthropic::ImageSource {
|
||||
source_type: "base64".to_string(),
|
||||
media_type: "image/png".to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue