Skip to content

Commit fc39116

Browse files
committed
修改: app/api/bedrock.ts
删除: app/api/bedrock/models.ts 删除: app/api/bedrock/utils.ts 修改: app/client/platforms/bedrock.ts 删除: app/components/chat-actions.tsx 修改: app/components/chat.tsx 修改: app/constant.ts 删除: app/icons/document.svg
1 parent dca4a0e commit fc39116

8 files changed

Lines changed: 355 additions & 1158 deletions

File tree

app/api/bedrock.ts

Lines changed: 350 additions & 60 deletions
Large diffs are not rendered by default.

app/api/bedrock/models.ts

Lines changed: 0 additions & 405 deletions
This file was deleted.

app/api/bedrock/utils.ts

Lines changed: 0 additions & 400 deletions
This file was deleted.

app/client/platforms/bedrock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export class BedrockApi implements LLMApi {
239239
// Add error message as text content
240240
content.push({
241241
type: "text",
242-
text: `Error processing image: ${e.message}`,
242+
text: `Error processing image: ${e}`,
243243
});
244244
}
245245
}

app/components/chat-actions.tsx

Lines changed: 0 additions & 188 deletions
This file was deleted.

app/components/chat.tsx

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import React, {
88
Fragment,
99
RefObject,
1010
} from "react";
11-
import DocumentIcon from "../icons/document.svg";
11+
1212
import SendWhiteIcon from "../icons/send-white.svg";
1313
import BrainIcon from "../icons/brain.svg";
1414
import RenameIcon from "../icons/rename.svg";
@@ -548,91 +548,6 @@ export function ChatActions(props: {
548548
);
549549
}
550550
}, [chatStore, currentModel, models]);
551-
const isBedrockProvider = currentProviderName === ServiceProvider.Bedrock;
552-
553-
// ... (rest of the existing state and functions)
554-
555-
async function uploadDocument() {
556-
const fileInput = document.createElement("input");
557-
fileInput.type = "file";
558-
fileInput.accept = ".pdf,.csv,.doc,.docx,.xls,.xlsx,.html,.txt,.md";
559-
fileInput.onchange = async (event: any) => {
560-
const file = event.target.files[0];
561-
if (!file) return;
562-
563-
props.setUploading(true);
564-
try {
565-
// Convert file to base64
566-
const base64 = await new Promise<string>((resolve, reject) => {
567-
const reader = new FileReader();
568-
reader.onload = (e) => {
569-
if (!e.target?.result) return reject("Failed to read file");
570-
const base64 = (e.target.result as string).split(",")[1];
571-
resolve(base64);
572-
};
573-
reader.onerror = reject;
574-
reader.readAsDataURL(file);
575-
});
576-
577-
// Get file extension
578-
const format = file.name.split(".").pop()?.toLowerCase() || "";
579-
const supportedFormats = [
580-
"pdf",
581-
"csv",
582-
"doc",
583-
"docx",
584-
"xls",
585-
"xlsx",
586-
"html",
587-
"txt",
588-
"md",
589-
];
590-
591-
if (!supportedFormats.includes(format)) {
592-
throw new Error("Unsupported file format");
593-
}
594-
595-
// Format file size
596-
const size = file.size;
597-
let sizeStr = "";
598-
if (size < 1024) {
599-
sizeStr = size + " B";
600-
} else if (size < 1024 * 1024) {
601-
sizeStr = (size / 1024).toFixed(2) + " KB";
602-
} else {
603-
sizeStr = (size / (1024 * 1024)).toFixed(2) + " MB";
604-
}
605-
606-
// Create document content with only filename and size
607-
const documentContent = {
608-
type: "document",
609-
document: {
610-
format,
611-
name: file.name,
612-
size: sizeStr,
613-
source: {
614-
bytes: base64,
615-
},
616-
},
617-
};
618-
619-
// Submit the document content as a JSON string but only display filename and size
620-
const displayContent = `Document: ${file.name} (${sizeStr})`;
621-
chatStore.onUserInput(displayContent);
622-
623-
// Store the actual document content separately if needed
624-
// chatStore.updateCurrentSession((session) => {
625-
// session.lastDocument = documentContent;
626-
// });
627-
} catch (error) {
628-
console.error("Failed to upload document:", error);
629-
showToast("Failed to upload document");
630-
} finally {
631-
props.setUploading(false);
632-
}
633-
};
634-
fileInput.click();
635-
}
636551

637552
return (
638553
<div className={styles["chat-input-actions"]}>
@@ -665,14 +580,6 @@ export function ChatActions(props: {
665580
icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}
666581
/>
667582
)}
668-
{/* Add document upload button for Bedrock */}
669-
{isBedrockProvider && (
670-
<ChatAction
671-
onClick={uploadDocument}
672-
text={Locale.Chat.InputActions.UploadDocument}
673-
icon={props.uploading ? <LoadingButtonIcon /> : <DocumentIcon />}
674-
/>
675-
)}
676583
<ChatAction
677584
onClick={nextTheme}
678585
text={Locale.Chat.InputActions.Theme[theme]}

app/constant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ const bedrockModels = [
316316
"anthropic.claude-3-opus-20240229-v1:0",
317317
"anthropic.claude-3-5-sonnet-20241022-v2:0",
318318
// Meta Llama Models
319-
"meta.llama3-2-11b-instruct-v1:0",
320-
"meta.llama3-2-90b-instruct-v1:0",
319+
"us.meta.llama3-2-11b-instruct-v1:0",
320+
"us.meta.llama3-2-90b-instruct-v1:0",
321321
//Mistral
322322
"mistral.mistral-large-2402-v1:0",
323323
"mistral.mistral-large-2407-v1:0",
@@ -529,7 +529,7 @@ export const DEFAULT_MODELS = [
529529
id: "bedrock",
530530
providerName: "Bedrock",
531531
providerType: "bedrock",
532-
sorted: 12,
532+
sorted: 13,
533533
},
534534
})),
535535
] as const;

app/icons/document.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)