fix: copilot blob process (#6612)
This commit is contained in:
@@ -113,8 +113,9 @@ export class OpenAIProvider
|
|||||||
!m ||
|
!m ||
|
||||||
// check content
|
// check content
|
||||||
typeof m.content !== 'string' ||
|
typeof m.content !== 'string' ||
|
||||||
!m.content ||
|
// content and attachments must exist at least one
|
||||||
!m.content.trim()
|
((!m.content || !m.content.trim()) &&
|
||||||
|
(!Array.isArray(m.attachments) || !m.attachments.length))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new Error('Empty message content');
|
throw new Error('Empty message content');
|
||||||
|
|||||||
@@ -280,7 +280,10 @@ export class CopilotResolver {
|
|||||||
options.attachments = options.attachments || [];
|
options.attachments = options.attachments || [];
|
||||||
const { workspaceId } = session.config;
|
const { workspaceId } = session.config;
|
||||||
|
|
||||||
for (const blob of await Promise.all(options.blobs)) {
|
const blobs = await Promise.all(options.blobs);
|
||||||
|
delete options.blobs;
|
||||||
|
|
||||||
|
for (const blob of blobs) {
|
||||||
const uploaded = await this.storage.handleUpload(user.id, blob);
|
const uploaded = await this.storage.handleUpload(user.id, blob);
|
||||||
const link = await this.storage.put(
|
const link = await this.storage.put(
|
||||||
user.id,
|
user.id,
|
||||||
@@ -289,7 +292,6 @@ export class CopilotResolver {
|
|||||||
uploaded.buffer
|
uploaded.buffer
|
||||||
);
|
);
|
||||||
options.attachments.push(link);
|
options.attachments.push(link);
|
||||||
delete options.blobs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user