Skip to content

Commit

Permalink
enhance: allow 100MB workspace file uploads
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams authored Mar 8, 2025
1 parent 1fd424d commit 8659129
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
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 {
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

0 comments on commit 8659129

Please sign in to comment.