Skip to content

Commit bd66147

Browse files
Fix upload button (#939)
Co-authored-by: Petr Bulánek <bulanek.petr@gmail.com>
1 parent da46cf5 commit bd66147

9 files changed

Lines changed: 64 additions & 8 deletions

File tree

agents/community/aider/src/aider_agent/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
@server.agent(
24+
input_content_types=["none"],
2425
metadata=Metadata(
2526
annotations=Annotations(
2627
beeai_ui=PlatformUIAnnotation(

agents/community/gpt-researcher/gpt_researcher_agent/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626

2727
@server.agent(
28+
input_content_types=["none"],
2829
metadata=Metadata(
2930
annotations=Annotations(
3031
beeai_ui=PlatformUIAnnotation(

agents/official/beeai-framework/chat/src/chat/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def to_framework_message(role: str, content: str) -> beeai_framework.backend.Mes
4040

4141

4242
@server.agent(
43+
input_content_types=["none"],
4344
metadata=Metadata(
4445
annotations=Annotations(
4546
beeai_ui=PlatformUIAnnotation(
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 © BeeAI a Series of LF Projects, LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""empty message
5+
6+
Revision ID: 975813acde2a
7+
Revises: 327991a3c7a7
8+
Create Date: 2025-07-17 15:39:56.507771
9+
10+
"""
11+
12+
from collections.abc import Sequence
13+
14+
import sqlalchemy as sa
15+
from alembic import op
16+
17+
# revision identifiers, used by Alembic.
18+
revision: str = "975813acde2a"
19+
down_revision: str | None = "327991a3c7a7"
20+
branch_labels: str | Sequence[str] | None = None
21+
depends_on: str | Sequence[str] | None = None
22+
23+
24+
def upgrade() -> None:
25+
"""Upgrade schema."""
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.add_column("agents", sa.Column("input_content_types", sa.JSON(), nullable=True))
28+
op.add_column("agents", sa.Column("output_content_types", sa.JSON(), nullable=True))
29+
# ### end Alembic commands ###
30+
31+
32+
def downgrade() -> None:
33+
"""Downgrade schema."""
34+
# ### commands auto generated by Alembic - please adjust! ###
35+
op.drop_column("agents", "output_content_types")
36+
op.drop_column("agents", "input_content_types")
37+
# ### end Alembic commands ###

apps/beeai-server/src/beeai_server/infrastructure/persistence/repositories/agent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
Column("description", Text, nullable=True),
2626
Column("provider_id", ForeignKey("providers.id", ondelete="CASCADE"), nullable=False),
2727
Column("metadata", JSON, nullable=False),
28+
Column("input_content_types", JSON, nullable=True),
29+
Column("output_content_types", JSON, nullable=True),
2830
)
2931

3032
agent_requests_table = Table(
@@ -55,6 +57,8 @@ async def bulk_create(self, agents: list[Agent]) -> None:
5557
"description": agent.description,
5658
"provider_id": agent.metadata.provider_id,
5759
"metadata": agent.metadata.model_dump(mode="json"),
60+
"input_content_types": agent.input_content_types,
61+
"output_content_types": agent.output_content_types,
5862
}
5963
for agent in agents
6064
]
@@ -84,6 +88,8 @@ def _to_agent(self, row: Row) -> Agent:
8488
"name": row.name,
8589
"description": row.description,
8690
"metadata": row.metadata,
91+
"input_content_types": row.input_content_types or ["*/*"],
92+
"output_content_types": row.output_content_types or ["*/*"],
8793
}
8894
)
8995

apps/beeai-ui/src/modules/runs/chat/ChatView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface Props {
2020

2121
export function ChatView({ agent }: Props) {
2222
return (
23-
<FileUploadProvider allowedContentTypes={agent.input_content_types ?? []}>
23+
<FileUploadProvider allowedContentTypes={agent.input_content_types}>
2424
<AgentRunProvider agent={agent}>
2525
<Chat />
2626
</AgentRunProvider>

apps/beeai-ui/src/modules/runs/files/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ export const FILE_CONTENT_URL = '/api/v1/files/{file_id}/content';
1212
export const FILE_CONTENT_URL_BASE = 'http://{platform_url}';
1313

1414
export const ALL_FILES_CONTENT_TYPE = '*/*';
15+
16+
export const NO_FILES_CONTENT_TYPE = 'none';

apps/beeai-ui/src/modules/runs/files/contexts/FileUploadProvider.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useToast } from '#contexts/Toast/index.ts';
1111

1212
import { useDeleteFile } from '../api/mutations/useDeleteFile';
1313
import { useUploadFile } from '../api/mutations/useUploadFile';
14-
import { ALL_FILES_CONTENT_TYPE, MAX_FILE_SIZE, MAX_FILES } from '../constants';
14+
import { ALL_FILES_CONTENT_TYPE, MAX_FILE_SIZE, MAX_FILES, NO_FILES_CONTENT_TYPE } from '../constants';
1515
import { type FileEntity, FileStatus } from '../types';
1616
import { FileUploadContext } from './file-upload-context';
1717

@@ -88,11 +88,19 @@ export function FileUploadProvider({ allowedContentTypes, children }: PropsWithC
8888
[files],
8989
);
9090

91-
const isDisabled = !allowedContentTypes.length;
92-
const accept = allowedContentTypes.reduce(
93-
(value, mimeType) => (mimeType === ALL_FILES_CONTENT_TYPE ? value : { ...value, [mimeType]: [] }),
94-
{} as Record<string, string[]>,
95-
);
91+
const isDisabled = allowedContentTypes.includes(NO_FILES_CONTENT_TYPE) || !allowedContentTypes.length;
92+
const accept = isDisabled
93+
? {}
94+
: allowedContentTypes.reduce(
95+
(value, mimeType) =>
96+
mimeType === ALL_FILES_CONTENT_TYPE
97+
? value
98+
: {
99+
...value,
100+
[mimeType]: [],
101+
},
102+
{} as Record<string, string[]>,
103+
);
96104

97105
const dropzone = useDropzone({
98106
accept,

apps/beeai-ui/src/modules/runs/hands-off/HandsOffView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface Props {
2020

2121
export function HandsOffView({ agent }: Props) {
2222
return (
23-
<FileUploadProvider allowedContentTypes={agent.input_content_types ?? []}>
23+
<FileUploadProvider allowedContentTypes={agent.input_content_types}>
2424
<AgentRunProvider agent={agent}>
2525
<HandsOff />
2626
</AgentRunProvider>

0 commit comments

Comments
 (0)