Documentation
¶
Index ¶
- Constants
- func CloseDaemons()
- func IsChatFinishMessage(msg string) error
- func IsDaemonRunning(url string) bool
- func SetPorts(start, end int64)
- func StopDaemon(url string)
- func WithToolCategory(ctx context.Context, toolCategory ToolCategory) context.Context
- type Call
- type CallContext
- type CallResult
- type ChatHistory
- type ChatHistoryCall
- type Context
- func (c *Context) CurrentAgent() types.ToolReference
- func (c *Context) GetCallContext() *CallContext
- func (c *Context) MarshalJSON() ([]byte, error)
- func (c *Context) OnUserCancel(ctx context.Context, cancel func())
- func (c *Context) ParentID() string
- func (c *Context) SubCallContext(ctx context.Context, input, toolID, callID string, toolCategory ToolCategory) (Context, error)
- func (c *Context) UnmarshalJSON([]byte) error
- func (c *Context) WrappedContext(e *Engine) context.Context
- type Engine
- type ErrChatFinish
- type InputContext
- type MCPRunner
- type Model
- type Ports
- type Return
- type RuntimeManager
- type State
- type StreamedBody
- type ToolCategory
Constants ¶
const AbortedSuffix = "\n\nABORTED BY USER"
const DaemonInstanceEnvVar = "GPTSCRIPT_DAEMON_INSTANCE"
DaemonInstanceEnvVar, when present in a daemon tool's environment, scopes the cached daemon to that value in addition to the tool ID. Callers that run multiple instances of the same daemon tool with per-instance configuration set it (e.g. to an instance UID) so each instance gets its own daemon process instead of silently sharing the first one that started.
const DaemonURLSuffix = ".daemon.gptscript.local"
Variables ¶
This section is empty.
Functions ¶
func CloseDaemons ¶
func CloseDaemons()
func IsChatFinishMessage ¶
func IsDaemonRunning ¶
func StopDaemon ¶
func StopDaemon(url string)
func WithToolCategory ¶
func WithToolCategory(ctx context.Context, toolCategory ToolCategory) context.Context
Types ¶
type CallContext ¶
type CallResult ¶
type ChatHistory ¶
type ChatHistory struct {
History []ChatHistoryCall `json:"history,omitempty"`
}
type ChatHistoryCall ¶
type ChatHistoryCall struct {
ID string `json:"id,omitempty"`
Tool types.Tool `json:"tool,omitempty"`
Completion types.CompletionRequest `json:"completion,omitempty"`
}
type Context ¶
type Context struct {
Ctx context.Context
Parent *Context
LastReturn *Return
CurrentReturn *Return
Engine *Engine
Program *types.Program
// Input is saved only so that we can render display text, don't use otherwise
Input string
// FilterCall marks the call the runner makes to an input or output filter
// itself. Unlike ToolCategory it is not inherited by SubCallContext, so a
// tool that a filter's model calls is not treated as a filter call.
FilterCall bool
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) CurrentAgent ¶
func (c *Context) CurrentAgent() types.ToolReference
func (*Context) GetCallContext ¶
func (c *Context) GetCallContext() *CallContext
func (*Context) MarshalJSON ¶
func (*Context) OnUserCancel ¶
func (*Context) SubCallContext ¶
func (*Context) UnmarshalJSON ¶
type Engine ¶
type Engine struct {
Model Model
RuntimeManager RuntimeManager
Env []string
Progress chan<- types.CompletionStatus
MCPRunner MCPRunner
}
type ErrChatFinish ¶
type ErrChatFinish struct {
Message string
}
func (*ErrChatFinish) Error ¶
func (e *ErrChatFinish) Error() string
type InputContext ¶
type Model ¶
type Model interface {
Call(ctx context.Context, messageRequest types.CompletionRequest, env []string, status chan<- types.CompletionStatus) (*types.CompletionMessage, error)
ProxyInfo([]string) (string, string, error)
}
type RuntimeManager ¶
type State ¶
type State struct {
Input string `json:"input,omitempty"`
Completion types.CompletionRequest `json:"completion,omitempty"`
Pending map[string]types.CompletionToolCall `json:"pending,omitempty"`
Results map[string]CallResult `json:"results,omitempty"`
}
type StreamedBody ¶
type StreamedBody struct {
// contains filtered or unexported fields
}
StreamedBody is the request body of an HTTP tool call, read from a stream rather than taken from the tool's input. A tool's input is a string that is copied several times on its way to the request (into the environment, into the body), so content too large to hold in memory several times over can only be sent this way.
func WithStreamedBody ¶
func WithStreamedBody(ctx context.Context, toolID, contentType string, r io.Reader) (context.Context, *StreamedBody)
WithStreamedBody returns a context in which the HTTP tool with ID toolID sends r as its request body, with the given content type, in place of the body it would build from its input. Everything else about the call is unchanged. r is sent at most once: a second call of that tool in the same context fails rather than sending an empty body.
func (*StreamedBody) Sent ¶
func (b *StreamedBody) Sent() bool
Sent reports whether the body was sent and the tool's server answered. A run that never called the tool, such as one whose tool is not an HTTP tool, returns without error and leaves this false.
type ToolCategory ¶
type ToolCategory string
const ( ProviderToolCategory ToolCategory = "provider" CredentialToolCategory ToolCategory = "credential" ContextToolCategory ToolCategory = "context" InputToolCategory ToolCategory = "input" OutputToolCategory ToolCategory = "output" NoCategory ToolCategory = "" )
func ToolCategoryFromContext ¶
func ToolCategoryFromContext(ctx context.Context) ToolCategory