Documentation
¶
Index ¶
- Constants
- func GetEnv(key, def string) string
- func ObjectSchema(kv ...string) *jsonschema.Schema
- type AuthResponse
- type Call
- type CallContext
- type CallFrame
- type CallFrames
- type ConflictInWorkspaceError
- type Credential
- type CredentialRequest
- type CredentialType
- type DatasetElement
- type DatasetElementMeta
- type DatasetMeta
- type DatasetOptions
- type DeleteFileInWorkspaceOptions
- type DeleteRevisionForFileInWorkspaceOptions
- type Document
- type ErrNotFound
- type EventType
- type Field
- type Fields
- type FileInfo
- type Frame
- type GPTScript
- func (g *GPTScript) AbortRun(ctx context.Context, run *Run) error
- func (g *GPTScript) AddDatasetElements(ctx context.Context, datasetID string, elements []DatasetElement, ...) (string, error)
- func (g *GPTScript) Close()
- func (g *GPTScript) Confirm(ctx context.Context, resp AuthResponse) error
- func (g *GPTScript) CreateCredential(ctx context.Context, cred Credential) error
- func (g *GPTScript) CreateDatasetWithElements(ctx context.Context, elements []DatasetElement, options ...DatasetOptions) (string, error)
- func (g *GPTScript) CreateWorkspace(ctx context.Context, providerType string, fromWorkspaces ...string) (string, error)
- func (g *GPTScript) DeleteCredential(ctx context.Context, credCtx, name string) error
- func (g *GPTScript) DeleteFileInWorkspace(ctx context.Context, filePath string, opts ...DeleteFileInWorkspaceOptions) error
- func (g *GPTScript) DeleteRevisionForFileInWorkspace(ctx context.Context, filePath, revisionID string, ...) error
- func (g *GPTScript) DeleteWorkspace(ctx context.Context, workspaceID string) error
- func (g *GPTScript) Evaluate(ctx context.Context, opts Options, tools ...ToolDef) (*Run, error)
- func (g *GPTScript) Fmt(ctx context.Context, nodes []Node) (string, error)
- func (g *GPTScript) GetDatasetElement(ctx context.Context, datasetID, elementName string) (DatasetElement, error)
- func (g *GPTScript) GetRevisionForFileInWorkspace(ctx context.Context, filePath, revisionID string, ...) ([]byte, error)
- func (g *GPTScript) ListCredentials(ctx context.Context, opts ListCredentialsOptions) ([]Credential, error)
- func (g *GPTScript) ListDatasetElements(ctx context.Context, datasetID string) ([]DatasetElementMeta, error)
- func (g *GPTScript) ListDatasets(ctx context.Context) ([]DatasetMeta, error)
- func (g *GPTScript) ListFilesInWorkspace(ctx context.Context, opts ...ListFilesInWorkspaceOptions) ([]string, error)
- func (g *GPTScript) ListModels(ctx context.Context, opts ...ListModelsOptions) ([]Model, error)
- func (g *GPTScript) ListRevisionsForFileInWorkspace(ctx context.Context, filePath string, ...) ([]FileInfo, error)
- func (g *GPTScript) LoadContent(ctx context.Context, content string, opts ...LoadOptions) (*Program, error)
- func (g *GPTScript) LoadFile(ctx context.Context, fileName string, opts ...LoadOptions) (*Program, error)
- func (g *GPTScript) LoadTools(ctx context.Context, toolDefs []ToolDef, opts ...LoadOptions) (*Program, error)
- func (g *GPTScript) Parse(ctx context.Context, fileName string, opts ...ParseOptions) ([]Node, error)
- func (g *GPTScript) ParseContent(ctx context.Context, toolDef string) ([]Node, error)
- func (g *GPTScript) PromptResponse(ctx context.Context, resp PromptResponse) error
- func (g *GPTScript) ReadFileInWorkspace(ctx context.Context, filePath string, opts ...ReadFileInWorkspaceOptions) ([]byte, error)
- func (g *GPTScript) ReadFileWithRevisionInWorkspace(ctx context.Context, filePath string, opts ...ReadFileInWorkspaceOptions) (*ReadFileWithRevisionInWorkspaceResponse, error)
- func (g *GPTScript) RecreateAllCredentials(ctx context.Context) error
- func (g *GPTScript) RemoveAll(ctx context.Context, opts ...RemoveAllOptions) error
- func (g *GPTScript) RevealCredential(ctx context.Context, credCtxs []string, name string) (Credential, error)
- func (g *GPTScript) Run(ctx context.Context, toolPath string, opts Options) (*Run, error)
- func (g *GPTScript) StatFileInWorkspace(ctx context.Context, filePath string, opts ...StatFileInWorkspaceOptions) (FileInfo, error)
- func (g *GPTScript) URL() string
- func (g *GPTScript) Version(ctx context.Context) (string, error)
- func (g *GPTScript) WriteFileInWorkspace(ctx context.Context, filePath string, contents []byte, ...) error
- type GetRevisionForFileInWorkspaceOptions
- type GlobalOptions
- type InputContext
- type ListCredentialsOptions
- type ListFilesInWorkspaceOptions
- type ListModelsOptions
- type ListRevisionsForFileInWorkspaceOptions
- type LoadOptions
- type Model
- type Node
- type NotFoundInWorkspaceError
- type Options
- type Output
- type ParseOptions
- type Permission
- type Program
- type Prompt
- type PromptFrame
- type PromptResponse
- type ReadFileInWorkspaceOptions
- type ReadFileWithRevisionInWorkspaceResponse
- type RemoveAllOptions
- type Repo
- type Run
- func (r *Run) Bytes() ([]byte, error)
- func (r *Run) Calls() CallFrames
- func (r *Run) ChatState() string
- func (r *Run) Close() error
- func (r *Run) Err() error
- func (r *Run) ErrorOutput() string
- func (r *Run) Events() <-chan Frame
- func (r *Run) NextChat(ctx context.Context, input string) (*Run, error)
- func (r *Run) ParentCallFrame() (CallFrame, bool)
- func (r *Run) Program() *Program
- func (r *Run) RawOutput() (map[string]any, error)
- func (r *Run) RespondingTool() Tool
- func (r *Run) State() RunState
- func (r *Run) Text() (string, error)
- func (r *Run) Usage() Usage
- type RunFrame
- type RunState
- type StatFileInWorkspaceOptions
- type TextNode
- type Tool
- type ToolCategory
- type ToolDef
- type ToolNode
- type ToolReference
- type ToolSet
- type ToolSource
- type Usage
- type WriteFileInWorkspaceOptions
Constants ¶
const ( ProviderToolCategory ToolCategory = "provider" CredentialToolCategory ToolCategory = "credential" ContextToolCategory ToolCategory = "context" InputToolCategory ToolCategory = "input" OutputToolCategory ToolCategory = "output" NoCategory ToolCategory = "" EventTypeRunStart EventType = "runStart" EventTypeCallStart EventType = "callStart" EventTypeCallContinue EventType = "callContinue" EventTypeCallSubCalls EventType = "callSubCalls" EventTypeCallProgress EventType = "callProgress" EventTypeChat EventType = "callChat" EventTypeCallConfirm EventType = "callConfirm" EventTypeCallFinish EventType = "callFinish" EventTypeRunFinish EventType = "runFinish" EventTypePrompt EventType = "prompt" )
Variables ¶
This section is empty.
Functions ¶
func ObjectSchema ¶
func ObjectSchema(kv ...string) *jsonschema.Schema
Types ¶
type AuthResponse ¶
type CallContext ¶
type CallContext struct {
ID string `json:"id"`
Tool Tool `json:"tool"`
AgentGroup []ToolReference `json:"agentGroup,omitempty"`
CurrentAgent ToolReference `json:"currentAgent,omitempty"`
DisplayText string `json:"displayText"`
InputContext []InputContext `json:"inputContext"`
ToolCategory ToolCategory `json:"toolCategory,omitempty"`
ToolName string `json:"toolName,omitempty"`
ParentID string `json:"parentID,omitempty"`
}
type CallFrame ¶
type CallFrame struct {
CallContext `json:",inline"`
Type EventType `json:"type"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Input string `json:"input"`
Output []Output `json:"output"`
Usage Usage `json:"usage"`
ChatResponseCached bool `json:"chatResponseCached"`
ToolResults int `json:"toolResults"`
LLMRequest any `json:"llmRequest"`
LLMResponse any `json:"llmResponse"`
}
type CallFrames ¶ added in v0.9.6
func (CallFrames) ParentCallFrame ¶ added in v0.9.6
func (c CallFrames) ParentCallFrame() CallFrame
type ConflictInWorkspaceError ¶ added in v0.9.6
type ConflictInWorkspaceError struct {
ID string
Name string
LatestRevision string
CurrentRevision string
}
func (*ConflictInWorkspaceError) Error ¶ added in v0.9.6
func (e *ConflictInWorkspaceError) Error() string
type Credential ¶ added in v0.9.5
type Credential struct {
Context string `json:"context"`
ToolName string `json:"toolName"`
Type CredentialType `json:"type"`
Env map[string]string `json:"env"`
Ephemeral bool `json:"ephemeral,omitempty"`
CheckParam string `json:"checkParam"`
ExpiresAt *time.Time `json:"expiresAt"`
RefreshToken string `json:"refreshToken"`
}
type CredentialRequest ¶ added in v0.9.5
type CredentialType ¶ added in v0.9.5
type CredentialType string
const ( CredentialTypeTool CredentialType = "tool" CredentialTypeModelProvider CredentialType = "modelProvider" )
type DatasetElement ¶ added in v0.9.6
type DatasetElement struct {
DatasetElementMeta `json:",inline"`
Contents string `json:"contents"`
BinaryContents []byte `json:"binaryContents"`
}
type DatasetElementMeta ¶ added in v0.9.6
type DatasetMeta ¶ added in v0.9.6
type DatasetOptions ¶ added in v0.9.6
type DatasetOptions struct {
Name, Description string
}
type DeleteFileInWorkspaceOptions ¶ added in v0.9.6
type DeleteFileInWorkspaceOptions struct {
WorkspaceID string
}
type DeleteRevisionForFileInWorkspaceOptions ¶ added in v0.9.6
type DeleteRevisionForFileInWorkspaceOptions struct {
WorkspaceID string
}
type ErrNotFound ¶ added in v0.9.5
type ErrNotFound struct {
Message string
}
func (ErrNotFound) Error ¶ added in v0.9.5
func (e ErrNotFound) Error() string
type Frame ¶
type Frame struct {
Run *RunFrame `json:"run,omitempty"`
Call *CallFrame `json:"call,omitempty"`
Prompt *PromptFrame `json:"prompt,omitempty"`
}
type GPTScript ¶
type GPTScript struct {
// contains filtered or unexported fields
}
func NewGPTScript ¶
func NewGPTScript(opts ...GlobalOptions) (*GPTScript, error)
func (*GPTScript) AddDatasetElements ¶ added in v0.9.6
func (g *GPTScript) AddDatasetElements(ctx context.Context, datasetID string, elements []DatasetElement, options ...DatasetOptions) (string, error)
func (*GPTScript) Confirm ¶
func (g *GPTScript) Confirm(ctx context.Context, resp AuthResponse) error
func (*GPTScript) CreateCredential ¶ added in v0.9.5
func (g *GPTScript) CreateCredential(ctx context.Context, cred Credential) error
func (*GPTScript) CreateDatasetWithElements ¶ added in v0.9.6
func (g *GPTScript) CreateDatasetWithElements(ctx context.Context, elements []DatasetElement, options ...DatasetOptions) (string, error)
func (*GPTScript) CreateWorkspace ¶ added in v0.9.6
func (*GPTScript) DeleteCredential ¶ added in v0.9.5
func (*GPTScript) DeleteFileInWorkspace ¶ added in v0.9.6
func (*GPTScript) DeleteRevisionForFileInWorkspace ¶ added in v0.9.6
func (*GPTScript) DeleteWorkspace ¶ added in v0.9.6
func (*GPTScript) GetDatasetElement ¶ added in v0.9.6
func (*GPTScript) GetRevisionForFileInWorkspace ¶ added in v0.9.6
func (*GPTScript) ListCredentials ¶ added in v0.9.5
func (g *GPTScript) ListCredentials(ctx context.Context, opts ListCredentialsOptions) ([]Credential, error)
func (*GPTScript) ListDatasetElements ¶ added in v0.9.6
func (*GPTScript) ListDatasets ¶ added in v0.9.6
func (g *GPTScript) ListDatasets(ctx context.Context) ([]DatasetMeta, error)
func (*GPTScript) ListFilesInWorkspace ¶ added in v0.9.6
func (*GPTScript) ListModels ¶
ListModels will list all the available models.
func (*GPTScript) ListRevisionsForFileInWorkspace ¶ added in v0.9.6
func (*GPTScript) LoadContent ¶ added in v0.9.5
func (g *GPTScript) LoadContent(ctx context.Context, content string, opts ...LoadOptions) (*Program, error)
LoadContent will load the given content into a Program.
func (*GPTScript) LoadFile ¶ added in v0.9.5
func (g *GPTScript) LoadFile(ctx context.Context, fileName string, opts ...LoadOptions) (*Program, error)
LoadFile will load the given file into a Program.
func (*GPTScript) LoadTools ¶ added in v0.9.5
func (g *GPTScript) LoadTools(ctx context.Context, toolDefs []ToolDef, opts ...LoadOptions) (*Program, error)
LoadTools will load the given tools into a Program.
func (*GPTScript) Parse ¶
func (g *GPTScript) Parse(ctx context.Context, fileName string, opts ...ParseOptions) ([]Node, error)
Parse will parse the given file into an array of Nodes.
func (*GPTScript) ParseContent ¶ added in v0.9.5
ParseContent will parse the given string into a tool.
func (*GPTScript) PromptResponse ¶
func (g *GPTScript) PromptResponse(ctx context.Context, resp PromptResponse) error
func (*GPTScript) ReadFileInWorkspace ¶ added in v0.9.6
func (*GPTScript) ReadFileWithRevisionInWorkspace ¶ added in v0.9.6
func (g *GPTScript) ReadFileWithRevisionInWorkspace(ctx context.Context, filePath string, opts ...ReadFileInWorkspaceOptions) (*ReadFileWithRevisionInWorkspaceResponse, error)
func (*GPTScript) RecreateAllCredentials ¶ added in v0.9.6
func (*GPTScript) RemoveAll ¶ added in v0.9.6
func (g *GPTScript) RemoveAll(ctx context.Context, opts ...RemoveAllOptions) error
func (*GPTScript) RevealCredential ¶ added in v0.9.5
func (*GPTScript) StatFileInWorkspace ¶ added in v0.9.6
func (*GPTScript) WriteFileInWorkspace ¶ added in v0.9.6
type GetRevisionForFileInWorkspaceOptions ¶ added in v0.9.6
type GetRevisionForFileInWorkspaceOptions struct {
WorkspaceID string
}
type GlobalOptions ¶
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"`
DatasetTool string `json:"DatasetTool"`
WorkspaceTool string `json:"WorkspaceTool"`
}
GlobalOptions allows specification of settings that are used for every call made. These options can be overridden by the corresponding Options.
type InputContext ¶
type ListCredentialsOptions ¶ added in v0.9.5
type ListFilesInWorkspaceOptions ¶ added in v0.9.6
type ListModelsOptions ¶ added in v0.9.5
type ListRevisionsForFileInWorkspaceOptions ¶ added in v0.9.6
type ListRevisionsForFileInWorkspaceOptions struct {
WorkspaceID string
}
type LoadOptions ¶ added in v0.9.5
type Node ¶
type Node struct {
TextNode *TextNode `json:"textNode,omitempty"`
ToolNode *ToolNode `json:"toolNode,omitempty"`
}
func ToolDefsToNodes ¶ added in v0.9.5
type NotFoundInWorkspaceError ¶ added in v0.9.6
type NotFoundInWorkspaceError struct {
// contains filtered or unexported fields
}
func (*NotFoundInWorkspaceError) Error ¶ added in v0.9.6
func (e *NotFoundInWorkspaceError) Error() string
type Options ¶
type Options struct {
GlobalOptions `json:",inline"`
DisableCache bool `json:"disableCache"`
Confirm bool `json:"confirm"`
Input string `json:"input"`
SubTool string `json:"subTool"`
Workspace string `json:"workspace"`
ChatState string `json:"chatState"`
IncludeEvents bool `json:"includeEvents"`
Prompt bool `json:"prompt"`
CredentialOverrides []string `json:"credentialOverrides"`
CredentialContexts []string `json:"credentialContexts"`
Location string `json:"location"`
ForceSequential bool `json:"forceSequential"`
}
Options represents options for the gptscript tool or file.
type ParseOptions ¶ added in v0.9.5
type ParseOptions struct {
DisableCache bool
}
type Permission ¶ added in v0.9.6
type Permission struct {
CreatedAt int64 `json:"created"`
ID string `json:"id"`
Object string `json:"object"`
AllowCreateEngine bool `json:"allow_create_engine"`
AllowSampling bool `json:"allow_sampling"`
AllowLogprobs bool `json:"allow_logprobs"`
AllowSearchIndices bool `json:"allow_search_indices"`
AllowView bool `json:"allow_view"`
AllowFineTuning bool `json:"allow_fine_tuning"`
Organization string `json:"organization"`
Group interface{} `json:"group"`
IsBlocking bool `json:"is_blocking"`
}
type PromptFrame ¶
type PromptFrame struct {
Prompt
ID string `json:"id,omitempty"`
Type EventType `json:"type,omitempty"`
Time time.Time `json:"time,omitempty"`
}
func (*PromptFrame) String ¶
func (p *PromptFrame) String() string
type PromptResponse ¶
type ReadFileInWorkspaceOptions ¶ added in v0.9.6
type ReadFileInWorkspaceOptions struct {
WorkspaceID string
}
type ReadFileWithRevisionInWorkspaceResponse ¶ added in v0.9.6
type RemoveAllOptions ¶ added in v0.9.6
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
func (*Run) Bytes ¶
Bytes returns the output of the gptscript in bytes. It blocks until the output is ready.
func (*Run) Calls ¶
func (r *Run) Calls() CallFrames
Calls will return a flattened array of the calls for this run.
func (*Run) ErrorOutput ¶
ErrorOutput returns the stderr output of the gptscript. Should only be called after Bytes or Text has returned an error.
func (*Run) Events ¶
Events returns a channel that streams the gptscript events as they occur as Frames.
func (*Run) NextChat ¶
NextChat will pass input and create the next run in a chat. The new Run will be returned.
func (*Run) ParentCallFrame ¶
ParentCallFrame returns the CallFrame for the top-level or "parent" call. The boolean indicates whether there is a parent CallFrame.
func (*Run) RawOutput ¶
RawOutput returns the raw output of the gptscript. Most users should use Text or Bytes instead.
func (*Run) RespondingTool ¶
RespondingTool returns the name of the tool that produced the output.
type RunFrame ¶
type RunFrame struct {
ID string `json:"id"`
Program Program `json:"program"`
Input string `json:"input"`
Output string `json:"output"`
Error string `json:"error"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
State RunState `json:"state"`
ChatState any `json:"chatState"`
Type EventType `json:"type"`
}
type StatFileInWorkspaceOptions ¶ added in v0.9.6
type Tool ¶
type Tool struct {
ToolDef `json:",inline"`
ID string `json:"id,omitempty"`
ToolMapping map[string][]ToolReference `json:"toolMapping,omitempty"`
LocalTools map[string]string `json:"localTools,omitempty"`
Source ToolSource `json:"source,omitempty"`
WorkingDir string `json:"workingDir,omitempty"`
}
type ToolCategory ¶
type ToolCategory string
type ToolDef ¶
type ToolDef struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
MaxTokens int `json:"maxTokens,omitempty"`
ModelName string `json:"modelName,omitempty"`
ModelProvider bool `json:"modelProvider,omitempty"`
JSONResponse bool `json:"jsonResponse,omitempty"`
Chat bool `json:"chat,omitempty"`
Temperature *float32 `json:"temperature,omitempty"`
Cache *bool `json:"cache,omitempty"`
InternalPrompt *bool `json:"internalPrompt"`
Arguments *jsonschema.Schema `json:"arguments,omitempty"`
Tools []string `json:"tools,omitempty"`
GlobalTools []string `json:"globalTools,omitempty"`
GlobalModelName string `json:"globalModelName,omitempty"`
Context []string `json:"context,omitempty"`
ExportContext []string `json:"exportContext,omitempty"`
Export []string `json:"export,omitempty"`
Agents []string `json:"agents,omitempty"`
Credentials []string `json:"credentials,omitempty"`
ExportCredentials []string `json:"exportCredentials,omitempty"`
InputFilters []string `json:"inputFilters,omitempty"`
ExportInputFilters []string `json:"exportInputFilters,omitempty"`
OutputFilters []string `json:"outputFilters,omitempty"`
ExportOutputFilters []string `json:"exportOutputFilters,omitempty"`
Instructions string `json:"instructions,omitempty"`
Type string `json:"type,omitempty"`
MetaData map[string]string `json:"metadata,omitempty"`
}
ToolDef struct represents a tool with various configurations.