Skip to content

Commit b0fa934

Browse files
docs(anthropic.md): update docs with file message usage
1 parent 62ad84f commit b0fa934

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

docs/my-website/docs/providers/anthropic.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,10 @@ response = completion(
10351035
"content": [
10361036
{"type": "text", "text": "You are a very professional document summarization specialist. Please summarize the given document."},
10371037
{
1038-
"type": "image_url",
1039-
"image_url": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
1038+
"type": "file",
1039+
"file": {
1040+
"file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
1041+
}
10401042
},
10411043
],
10421044
}
@@ -1081,8 +1083,10 @@ curl http://0.0.0.0:4000/v1/chat/completions \
10811083
"text": "You are a very professional document summarization specialist. Please summarize the given document"
10821084
},
10831085
{
1084-
"type": "image_url",
1085-
"image_url": "data:application/pdf;base64,{encoded_file}" # 👈 PDF
1086+
"type": "file",
1087+
"file": {
1088+
"file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
1089+
}
10861090
}
10871091
}
10881092
]

docs/my-website/docs/providers/bedrock.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,14 +1168,22 @@ os.environ["AWS_REGION_NAME"] = ""
11681168
# pdf url
11691169
image_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
11701170
1171+
# Download the file
1172+
response = requests.get(url)
1173+
file_data = response.content
1174+
1175+
encoded_file = base64.b64encode(file_data).decode("utf-8")
1176+
11711177
# model
11721178
model = "bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0"
11731179
11741180
image_content = [
11751181
{"type": "text", "text": "What's this file about?"},
11761182
{
1177-
"type": "image_url",
1178-
"image_url": image_url, # OR {"url": image_url}
1183+
"type": "file",
1184+
"file": {
1185+
"file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
1186+
}
11791187
},
11801188
]
11811189
@@ -1221,8 +1229,10 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \
12211229
"messages": [
12221230
{"role": "user", "content": {"type": "text", "text": "What's this file about?"}},
12231231
{
1224-
"type": "image_url",
1225-
"image_url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
1232+
"type": "file",
1233+
"file": {
1234+
"file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
1235+
}
12261236
}
12271237
]
12281238
}'

0 commit comments

Comments
 (0)