Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: allow 100MB workspace file uploads #1979

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/api/handlers/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,15 @@ func (a *AgentHandler) UploadFile(req api.Context) error {
return err
}

if err := uploadFile(req.Context(), req, a.gptscript, workspaceName); err != nil {
var ws v1.Workspace
if err := req.Get(&ws, workspaceName); err != nil {
return fmt.Errorf("failed to get workspace with id %s: %w", workspaceName, err)
}

if _, err := uploadFileToWorkspace(req.Context(), req, a.gptscript, ws.Status.WorkspaceID, "files/", api.BodyOptions{
// 100MB
MaxBytes: 100 * 1024 * 1024,
}); err != nil {
return err
}

Expand Down
15 changes: 4 additions & 11 deletions pkg/api/handlers/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ func (f *FilesHandler) UploadFile(req api.Context) error {
return types.NewErrNotFound("no workspace found")
}

_, err = uploadFileToWorkspace(req.Context(), req, f.gptScript, thread.Status.WorkspaceID, "files/")
_, err = uploadFileToWorkspace(req.Context(), req, f.gptScript, thread.Status.WorkspaceID, "files/", api.BodyOptions{
// 100MB
MaxBytes: 100 * 1024 * 1024,
})
return err
}

Expand Down Expand Up @@ -282,16 +285,6 @@ func convertFile(file, prefix string) types.File {
}
}

func uploadFile(ctx context.Context, req api.Context, gClient *gptscript.GPTScript, workspaceName string) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only used in one spot, so I removed its contents to where it is being used to avoid confusion.

var ws v1.Workspace
if err := req.Get(&ws, workspaceName); err != nil {
return fmt.Errorf("failed to get workspace with id %s: %w", workspaceName, err)
}

_, err := uploadFileToWorkspace(ctx, req, gClient, ws.Status.WorkspaceID, "files/")
return err
}

func getFileInWorkspace(ctx context.Context, req api.Context, gClient *gptscript.GPTScript, workspaceID, prefix string) error {
file := req.PathValue("file")
if file == "" {
Expand Down
Loading