Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ package gptscript
// GlobalOptions allows specification of settings that are used for every call made.
// These options can be overridden by the corresponding Options.
type GlobalOptions struct {
URL string `json:"url"`
Token string `json:"token"`
OpenAIAPIKey string `json:"APIKey"`
OpenAIBaseURL string `json:"BaseURL"`
DefaultModel string `json:"DefaultModel"`
DefaultModelProvider string `json:"DefaultModelProvider"`
CacheDir string `json:"CacheDir"`
Env []string `json:"env"`
DatasetToolRepo string `json:"DatasetToolRepo"`
WorkspaceTool string `json:"WorkspaceTool"`
WorkspaceDirectoryDataHome string `json:"WorkspaceDirectoryDataHome"`
URL string `json:"url"`
Token string `json:"token"`
OpenAIAPIKey string `json:"APIKey"`
OpenAIBaseURL string `json:"BaseURL"`
DefaultModel string `json:"DefaultModel"`
DefaultModelProvider string `json:"DefaultModelProvider"`
CacheDir string `json:"CacheDir"`
Env []string `json:"env"`
DatasetToolRepo string `json:"DatasetToolRepo"`
WorkspaceTool string `json:"WorkspaceTool"`
}

func (g GlobalOptions) toEnv() []string {
Expand All @@ -30,9 +29,6 @@ func (g GlobalOptions) toEnv() []string {
if g.DefaultModelProvider != "" {
args = append(args, "GPTSCRIPT_SDKSERVER_DEFAULT_MODEL_PROVIDER="+g.DefaultModelProvider)
}
if g.WorkspaceDirectoryDataHome != "" {
args = append(args, "GPTSCRIPT_WORKSPACE_DIR="+g.WorkspaceDirectoryDataHome)
}

return args
}
Expand All @@ -49,7 +45,6 @@ func completeGlobalOptions(opts ...GlobalOptions) GlobalOptions {
result.DefaultModelProvider = firstSet(opt.DefaultModelProvider, result.DefaultModelProvider)
result.DatasetToolRepo = firstSet(opt.DatasetToolRepo, result.DatasetToolRepo)
result.WorkspaceTool = firstSet(opt.WorkspaceTool, result.WorkspaceTool)
result.WorkspaceDirectoryDataHome = firstSet(opt.WorkspaceDirectoryDataHome, result.WorkspaceDirectoryDataHome)
result.Env = append(result.Env, opt.Env...)
}
return result
Expand Down
9 changes: 4 additions & 5 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (

func (g *GPTScript) CreateWorkspace(ctx context.Context, providerType string, fromWorkspaces ...string) (string, error) {
out, err := g.runBasicCommand(ctx, "workspaces/create", map[string]any{
"providerType": providerType,
"fromWorkspaceIDs": fromWorkspaces,
"workspaceTool": g.globalOpts.WorkspaceTool,
"directoryDataHome": g.globalOpts.WorkspaceDirectoryDataHome,
"env": g.globalOpts.Env,
"providerType": providerType,
"fromWorkspaceIDs": fromWorkspaces,
"workspaceTool": g.globalOpts.WorkspaceTool,
"env": g.globalOpts.Env,
})
if err != nil {
return "", err
Expand Down