fix: do not create hash in frontend (#6788)
blob is already hashed in 6fdf45d4d0/packages/backend/server/src/plugins/copilot/resolver.ts (L294)
This commit is contained in:
@@ -8,16 +8,6 @@ const TIMEOUT = 50000;
|
|||||||
|
|
||||||
const client = new CopilotClient();
|
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 = {
|
export type TextToTextOptions = {
|
||||||
docId: string;
|
docId: string;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
@@ -86,7 +76,7 @@ async function createSessionMessage({
|
|||||||
if (blob instanceof File) {
|
if (blob instanceof File) {
|
||||||
return blob;
|
return blob;
|
||||||
} else {
|
} else {
|
||||||
return new File([blob], await calculateBlobHash(blob), {
|
return new File([blob], sessionId, {
|
||||||
type: blob.type,
|
type: blob.type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user