Skip to content

Commit

Permalink
add workspaceID arg
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville committed Oct 23, 2024
1 parent 1ebbecc commit 9e4bf1e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/sdkserver/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ import (

type datasetRequest struct {
Input string `json:"input"`
WorkspaceID string `json:"workspaceID"`
DatasetToolRepo string `json:"datasetToolRepo"`
}

func (r datasetRequest) validate(requireInput bool) error {
if requireInput && r.Input == "" {
if r.WorkspaceID == "" {
return fmt.Errorf("workspaceID is required")
} else if requireInput && r.Input == "" {
return fmt.Errorf("input is required")
}
return nil
}

func (r datasetRequest) opts(o gptscript.Options) gptscript.Options {
opts := gptscript.Options{
Cache: o.Cache,
Monitor: o.Monitor,
Runner: o.Runner,
Cache: o.Cache,
Monitor: o.Monitor,
Runner: o.Runner,
Workspace: r.WorkspaceID,
}
return opts
}
Expand Down Expand Up @@ -269,7 +273,7 @@ func (s *server) addDatasetElements(w http.ResponseWriter, r *http.Request) {
return
}

result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, fmt.Sprintf(`{"datasetID":%q, elements:%s}`, args.DatasetID, elementsJSON))
result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, fmt.Sprintf(`{"datasetID":%q, "elements":%q}`, args.DatasetID, string(elementsJSON)))
if err != nil {
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))
return
Expand Down

0 comments on commit 9e4bf1e

Please sign in to comment.