Skip to content

Commit

Permalink
fix: copilot blob process (#6612)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Apr 18, 2024
1 parent a537f8e commit 5005882
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ export class OpenAIProvider
!m ||
// check content
typeof m.content !== 'string' ||
!m.content ||
!m.content.trim()
// content and attachments must exist at least one
((!m.content || !m.content.trim()) &&
(!Array.isArray(m.attachments) || !m.attachments.length))
)
) {
throw new Error('Empty message content');
Expand Down
6 changes: 4 additions & 2 deletions packages/backend/server/src/plugins/copilot/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ export class CopilotResolver {
options.attachments = options.attachments || [];
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 link = await this.storage.put(
user.id,
Expand All @@ -289,7 +292,6 @@ export class CopilotResolver {
uploaded.buffer
);
options.attachments.push(link);
delete options.blobs;
}
}

Expand Down

0 comments on commit 5005882

Please sign in to comment.