File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed
docs/my-website/docs/providers Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -1035,8 +1035,10 @@ response = completion(
1035
1035
" content" : [
1036
1036
{" type" : " text" , " text" : " You are a very professional document summarization specialist. Please summarize the given document." },
1037
1037
{
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
+ }
1040
1042
},
1041
1043
],
1042
1044
}
@@ -1081,8 +1083,10 @@ curl http://0.0.0.0:4000/v1/chat/completions \
1081
1083
"text": "You are a very professional document summarization specialist. Please summarize the given document"
1082
1084
},
1083
1085
{
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
+ }
1086
1090
}
1087
1091
}
1088
1092
]
Original file line number Diff line number Diff line change @@ -1168,14 +1168,22 @@ os.environ["AWS_REGION_NAME"] = ""
1168
1168
# pdf url
1169
1169
image_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
1170
1170
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
+
1171
1177
# model
1172
1178
model = "bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0"
1173
1179
1174
1180
image_content = [
1175
1181
{"type": "text", "text": "What's this file about?"},
1176
1182
{
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
+ }
1179
1187
},
1180
1188
]
1181
1189
@@ -1221,8 +1229,10 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \
1221
1229
"messages": [
1222
1230
{"role": "user", "content": {"type": "text", "text": "What's this file about?"}},
1223
1231
{
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
+ }
1226
1236
}
1227
1237
]
1228
1238
}'
You can’t perform that action at this time.
0 commit comments