Skip to content

Commit

Permalink
add env to the request
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 9e4bf1e commit f402c56
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/sdkserver/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
)

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

func (r datasetRequest) validate(requireInput bool) error {
Expand Down Expand Up @@ -71,7 +72,7 @@ func (s *server) listDatasets(w http.ResponseWriter, r *http.Request) {
return
}

result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, req.Input)
result, err := g.Run(r.Context(), prg, req.Env, req.Input)
if err != nil {
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))
return
Expand Down Expand Up @@ -132,7 +133,7 @@ func (s *server) createDataset(w http.ResponseWriter, r *http.Request) {
return
}

result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, req.Input)
result, err := g.Run(r.Context(), prg, req.Env, req.Input)
if err != nil {
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))
return
Expand Down Expand Up @@ -200,7 +201,7 @@ func (s *server) addDatasetElement(w http.ResponseWriter, r *http.Request) {
return
}

result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, req.Input)
result, err := g.Run(r.Context(), prg, req.Env, req.Input)
if err != nil {
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))
return
Expand Down Expand Up @@ -273,7 +274,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":%q}`, args.DatasetID, string(elementsJSON)))
result, err := g.Run(r.Context(), prg, req.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 Expand Up @@ -332,7 +333,7 @@ func (s *server) listDatasetElements(w http.ResponseWriter, r *http.Request) {
return
}

result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, req.Input)
result, err := g.Run(r.Context(), prg, req.Env, req.Input)
if err != nil {
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))
return
Expand Down Expand Up @@ -395,7 +396,7 @@ func (s *server) getDatasetElement(w http.ResponseWriter, r *http.Request) {
return
}

result, err := g.Run(r.Context(), prg, s.gptscriptOpts.Env, req.Input)
result, err := g.Run(r.Context(), prg, req.Env, req.Input)
if err != nil {
writeError(logger, w, http.StatusInternalServerError, fmt.Errorf("failed to run program: %w", err))
return
Expand Down

0 comments on commit f402c56

Please sign in to comment.