Skip to content

Commit bd40d81

Browse files
committed
changes per comments
1 parent 646d3b9 commit bd40d81

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

src/providers/anthropic/chatComplete.ts

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,26 @@ interface AnthropicTextContentItem {
6464
}
6565

6666
interface AnthropicUrlPdfContentItem {
67-
type: 'document';
67+
type: string;
6868
source: {
69-
type: 'url';
69+
type: string;
7070
url: string;
7171
};
7272
}
7373

7474
interface AnthropicBase64PdfContentItem {
75-
type: 'document';
75+
type: string;
7676
source: {
77-
type: 'base64';
77+
type: string;
7878
data: string;
7979
media_type: string;
8080
};
8181
}
8282

8383
interface AnthropicPlainTextContentItem {
84-
type: 'document';
84+
type: string;
8585
source: {
86-
type: 'text';
86+
type: string;
8787
data: string;
8888
media_type: string;
8989
};
@@ -213,25 +213,14 @@ const transformAndAppendFileContentItem = (
213213
} else if (item.file?.file_data) {
214214
const contentType =
215215
mimeType === fileExtensionMimeTypeMap.txt ? 'text' : 'base64';
216-
if (contentType === 'text') {
217-
transformedMessage.content.push({
218-
type: 'document',
219-
source: {
220-
type: contentType,
221-
data: item.file.file_data,
222-
media_type: mimeType,
223-
},
224-
});
225-
} else {
226-
transformedMessage.content.push({
227-
type: 'document',
228-
source: {
229-
type: contentType,
230-
data: item.file.file_data,
231-
media_type: mimeType,
232-
},
233-
});
234-
}
216+
transformedMessage.content.push({
217+
type: 'document',
218+
source: {
219+
type: contentType,
220+
data: item.file.file_data,
221+
media_type: mimeType,
222+
},
223+
});
235224
}
236225
};
237226

src/providers/bedrock/chatComplete.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ const getMessageContent = (message: Message) => {
188188
out.push({
189189
document: {
190190
format: fileFormat,
191-
name: crypto.randomUUID(),
191+
name: item.file.file_name || crypto.randomUUID(),
192192
source: {
193193
s3Location: {
194194
uri: item.file.file_url,
@@ -200,7 +200,7 @@ const getMessageContent = (message: Message) => {
200200
out.push({
201201
document: {
202202
format: fileFormat,
203-
name: crypto.randomUUID(),
203+
name: item.file.file_name || crypto.randomUUID(),
204204
source: {
205205
bytes: item.file.file_data,
206206
},

0 commit comments

Comments
 (0)