Skip to content

Commit c0bce9c

Browse files
authored
Merge pull request #85 from voicekick/anthropic/add_support_for_pdf
anthropic: add support for pdf
2 parents bed2c17 + 724bd88 commit c0bce9c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/backends/anthropic.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,23 @@ impl ChatProvider for Anthropic {
370370
tool_result_id: None,
371371
tool_output: None,
372372
}],
373-
MessageType::Pdf(_) => unimplemented!(),
373+
MessageType::Pdf(raw_bytes) => {
374+
vec![MessageContent {
375+
message_type: Some("document"),
376+
text: None,
377+
image_url: None,
378+
source: Some(ImageSource {
379+
source_type: "base64",
380+
media_type: "application/pdf",
381+
data: BASE64.encode(raw_bytes),
382+
}),
383+
tool_use_id: None,
384+
tool_input: None,
385+
tool_name: None,
386+
tool_result_id: None,
387+
tool_output: None,
388+
}]
389+
}
374390
MessageType::Image((image_mime, raw_bytes)) => {
375391
vec![MessageContent {
376392
message_type: Some("image"),

0 commit comments

Comments
 (0)