Skip to content

Commit

Permalink
remove dataset tool repo as a GPTScript option
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 10, 2024
1 parent 955ad9c commit 175a8e3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
2 changes: 0 additions & 2 deletions pkg/cli/gptscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ type GPTScript struct {
SaveChatStateFile string `usage:"A file to save the chat state to so that a conversation can be resumed with --chat-state" local:"true"`
DefaultModelProvider string `usage:"Default LLM model provider to use, this will override OpenAI settings"`
GithubEnterpriseHostname string `usage:"The host name for a Github Enterprise instance to enable for remote loading" local:"true"`
DatasetToolRepo string `usage:"The repo to use for dataset tools" default:"github.com/gptscript-ai/datasets" local:"true"`

readData []byte
}
Expand Down Expand Up @@ -147,7 +146,6 @@ func (r *GPTScript) NewGPTScriptOpts() (gptscript.Options, error) {
Workspace: r.Workspace,
DisablePromptServer: r.UI,
DefaultModelProvider: r.DefaultModelProvider,
DatasetToolRepo: r.DatasetToolRepo,
}

if r.Confirm {
Expand Down
2 changes: 0 additions & 2 deletions pkg/gptscript/gptscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type Options struct {
CredentialContexts []string
Quiet *bool
Workspace string
DatasetToolRepo string
DisablePromptServer bool
Env []string
}
Expand All @@ -67,7 +66,6 @@ func Complete(opts ...Options) Options {
result.CredentialContexts = opt.CredentialContexts
result.Quiet = types.FirstSet(opt.Quiet, result.Quiet)
result.Workspace = types.FirstSet(opt.Workspace, result.Workspace)
result.DatasetToolRepo = types.FirstSet(opt.DatasetToolRepo, result.DatasetToolRepo)
result.Env = append(result.Env, opt.Env...)
result.DisablePromptServer = types.FirstSet(opt.DisablePromptServer, result.DisablePromptServer)
result.DefaultModelProvider = types.FirstSet(opt.DefaultModelProvider, result.DefaultModelProvider)
Expand Down
27 changes: 15 additions & 12 deletions pkg/sdkserver/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ func (r datasetRequest) validate(requireInput bool) error {

func (r datasetRequest) opts(o gptscript.Options) gptscript.Options {
opts := gptscript.Options{
Cache: o.Cache,
Monitor: o.Monitor,
Runner: o.Runner,
DatasetToolRepo: o.DatasetToolRepo,
Workspace: r.Workspace,
Cache: o.Cache,
Monitor: o.Monitor,
Runner: o.Runner,
Workspace: r.Workspace,
}
return opts
}

func (r datasetRequest) getToolRepo() string {
if r.DatasetToolRepo != "" {
opts.DatasetToolRepo = r.DatasetToolRepo
return r.DatasetToolRepo
}
return opts
return "github.com/gptscript-ai/datasets"
}

func (s *server) listDatasets(w http.ResponseWriter, r *http.Request) {
Expand All @@ -59,7 +62,7 @@ func (s *server) listDatasets(w http.ResponseWriter, r *http.Request) {
return
}

prg, err := loader.Program(r.Context(), "List Datasets from "+s.gptscriptOpts.DatasetToolRepo, "", loader.Options{
prg, err := loader.Program(r.Context(), "List Datasets from "+req.getToolRepo(), "", loader.Options{
Cache: g.Cache,
})

Expand Down Expand Up @@ -120,7 +123,7 @@ func (s *server) createDataset(w http.ResponseWriter, r *http.Request) {
return
}

prg, err := loader.Program(r.Context(), "Create Dataset from "+s.gptscriptOpts.DatasetToolRepo, "", loader.Options{
prg, err := loader.Program(r.Context(), "Create Dataset from "+req.getToolRepo(), "", loader.Options{
Cache: g.Cache,
})

Expand Down Expand Up @@ -189,7 +192,7 @@ func (s *server) addDatasetElement(w http.ResponseWriter, r *http.Request) {
return
}

prg, err := loader.Program(r.Context(), "Add Element from "+s.gptscriptOpts.DatasetToolRepo, "", loader.Options{
prg, err := loader.Program(r.Context(), "Add Element from "+req.getToolRepo(), "", loader.Options{
Cache: g.Cache,
})
if err != nil {
Expand Down Expand Up @@ -248,7 +251,7 @@ func (s *server) listDatasetElements(w http.ResponseWriter, r *http.Request) {
return
}

prg, err := loader.Program(r.Context(), "List Elements from "+s.gptscriptOpts.DatasetToolRepo, "", loader.Options{
prg, err := loader.Program(r.Context(), "List Elements from "+req.getToolRepo(), "", loader.Options{
Cache: g.Cache,
})
if err != nil {
Expand Down Expand Up @@ -311,7 +314,7 @@ func (s *server) getDatasetElement(w http.ResponseWriter, r *http.Request) {
return
}

prg, err := loader.Program(r.Context(), "Get Element from "+s.gptscriptOpts.DatasetToolRepo, "", loader.Options{
prg, err := loader.Program(r.Context(), "Get Element from "+req.getToolRepo(), "", loader.Options{
Cache: g.Cache,
})
if err != nil {
Expand Down
6 changes: 0 additions & 6 deletions pkg/sdkserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/rs/cors"
)

const defaultDatasetToolRepo = "github.com/gptscript-ai/datasets"

type Options struct {
gptscript.Options

Expand Down Expand Up @@ -167,9 +165,5 @@ func complete(opts ...Options) Options {
result.ListenAddress = "127.0.0.1:0"
}

if result.DatasetToolRepo == "" {
result.DatasetToolRepo = defaultDatasetToolRepo
}

return result
}

0 comments on commit 175a8e3

Please sign in to comment.