pengx17
2024-05-07 03:50:30 +00:00
parent 82d4aa8dff
commit 12806b0e7b
@@ -8,16 +8,6 @@ const TIMEOUT = 50000;
const client = new CopilotClient();
async function calculateBlobHash(blob: Blob) {
const buffer = await blob.arrayBuffer();
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray
.map(byte => byte.toString(16).padStart(2, '0'))
.join('')
.slice(0, 32);
}
export type TextToTextOptions = {
docId: string;
workspaceId: string;
@@ -86,7 +76,7 @@ async function createSessionMessage({
if (blob instanceof File) {
return blob;
} else {
return new File([blob], await calculateBlobHash(blob), {
return new File([blob], sessionId, {
type: blob.type,
});
}