Skip to content

Commit 9e4bf1e

Browse files
committed
add workspaceID arg
Signed-off-by: Grant Linville <[email protected]>
1 parent 1ebbecc commit 9e4bf1e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pkg/sdkserver/datasets.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ import (
1212

1313
type datasetRequest struct {
1414
Input string `json:"input"`
15+
WorkspaceID string `json:"workspaceID"`
1516
DatasetToolRepo string `json:"datasetToolRepo"`
1617
}
1718

1819
func (r datasetRequest) validate(requireInput bool) error {
19-
if requireInput && r.Input == "" {
20+
if r.WorkspaceID == "" {
21+
return fmt.Errorf("workspaceID is required")
22+
} else if requireInput && r.Input == "" {
2023
return fmt.Errorf("input is required")
2124
}
2225
return nil
2326
}
2427

2528
func (r datasetRequest) opts(o gptscript.Options) gptscript.Options {
2629
opts := gptscript.Options{
27-
Cache: o.Cache,
28-
Monitor: o.Monitor,
29-
Runner: o.Runner,
30+
Cache: o.Cache,
31+
Monitor: o.Monitor,
32+
Runner: o.Runner,
33+
Workspace: r.WorkspaceID,
3034
}
3135
return opts
3236
}
@@ -269,7 +273,7 @@ func (s *server) addDatasetElements(w http.ResponseWriter, r *http.Request) {
269273
return
270274
}
271275

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

0 commit comments

Comments
 (0)