types

package
v0.1.3-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

View Source
const (
	CompletionMessageRoleTypeUser      = CompletionMessageRoleType("user")
	CompletionMessageRoleTypeSystem    = CompletionMessageRoleType("system")
	CompletionMessageRoleTypeAssistant = CompletionMessageRoleType("assistant")
	CompletionMessageRoleTypeTool      = CompletionMessageRoleType("tool")
)

Chat message role defined by the OpenAI API.

View Source
const (
	DaemonPrefix  = "#!sys.daemon"
	CommandPrefix = "#!"
)

Variables

This section is empty.

Functions

func FirstSet

func FirstSet[T comparable](in ...T) (result T)

Types

type BuiltinFunc

type BuiltinFunc func(ctx context.Context, env []string, input string) (string, error)

type CompletionFunctionCall

type CompletionFunctionCall struct {
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

type CompletionFunctionDefinition

type CompletionFunctionDefinition struct {
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	Domain      string      `json:"domain,omitempty"`
	Parameters  *JSONSchema `json:"parameters"`
}

type CompletionMessage

type CompletionMessage struct {
	Role     CompletionMessageRoleType `json:"role,omitempty"`
	Content  []ContentPart             `json:"content,omitempty" column:"name=Message,jsonpath=.spec.content"`
	ToolCall *CompletionToolCall       `json:"toolCall,omitempty"`
}

func (CompletionMessage) IsToolCall

func (in CompletionMessage) IsToolCall() bool

func (CompletionMessage) String

func (in CompletionMessage) String() string

type CompletionMessageRoleType

type CompletionMessageRoleType string

type CompletionRequest

type CompletionRequest struct {
	Model        string
	Vision       bool
	Tools        []CompletionTool
	Messages     []CompletionMessage
	MaxToken     int
	Temperature  *float32
	JSONResponse bool
	Cache        *bool
}

type CompletionTool

type CompletionTool struct {
	Type     CompletionToolType           `json:"type"`
	Function CompletionFunctionDefinition `json:"function,omitempty"`
}

type CompletionToolCall

type CompletionToolCall struct {
	Index    *int                   `json:"index,omitempty"`
	ID       string                 `json:"id,omitempty"`
	Type     CompletionToolType     `json:"type,omitempty"`
	Function CompletionFunctionCall `json:"function,omitempty"`
}

type CompletionToolType

type CompletionToolType string
const (
	CompletionToolTypeFunction CompletionToolType = "function"
)

type ContentPart

type ContentPart struct {
	Text     string              `json:"text,omitempty"`
	ToolCall *CompletionToolCall `json:"toolCall,omitempty"`
	Image    *ImageURL           `json:"image,omitempty"`
}

func Text

func Text(text string) []ContentPart

type ImageURL

type ImageURL struct {
	Base64      string         `json:"base64,omitempty"`
	ContentType string         `json:"contentType,omitempty"`
	URL         string         `json:"url,omitempty"`
	Detail      ImageURLDetail `json:"detail,omitempty"`
}

type ImageURLDetail

type ImageURLDetail string
const (
	ImageURLDetailHigh ImageURLDetail = "high"
	ImageURLDetailLow  ImageURLDetail = "low"
	ImageURLDetailAuto ImageURLDetail = "auto"
)

type JSONSchema

type JSONSchema struct {
	Property

	ID         string                `json:"$id,omitempty"`
	Title      string                `json:"title,omitempty"`
	Properties map[string]Property   `json:"properties"`
	Required   []string              `json:"required,omitempty"`
	Defs       map[string]JSONSchema `json:"defs,omitempty"`

	AdditionalProperties bool `json:"additionalProperties,omitempty"`
}

func ObjectSchema

func ObjectSchema(kv ...string) *JSONSchema

type Parameters

type Parameters struct {
	Name           string      `json:"name,omitempty"`
	Description    string      `json:"description,omitempty"`
	Vision         bool        `json:"vision,omitempty"`
	MaxTokens      int         `json:"maxTokens,omitempty"`
	ModelName      string      `json:"modelName,omitempty"`
	JSONResponse   bool        `json:"jsonResponse,omitempty"`
	Temperature    *float32    `json:"temperature,omitempty"`
	Cache          *bool       `json:"cache,omitempty"`
	InternalPrompt *bool       `json:"internalPrompt"`
	Arguments      *JSONSchema `json:"arguments,omitempty"`
	Tools          []string    `json:"tools,omitempty"`
}

type Program

type Program struct {
	Name        string            `json:"name,omitempty"`
	EntryToolID string            `json:"entryToolId,omitempty"`
	ToolSet     ToolSet           `json:"toolSet,omitempty"`
	Exports     map[string]string `json:"exports,omitempty"`
}

type Property

type Property struct {
	Description string       `json:"description,omitempty"`
	Type        string       `json:"type,omitempty"`
	Ref         string       `json:"$ref,omitempty"`
	Items       []JSONSchema `json:"items,omitempty"`
}

type Tool

type Tool struct {
	Parameters   `json:",inline"`
	Instructions string `json:"instructions,omitempty"`

	ID          string            `json:"id,omitempty"`
	ToolMapping map[string]string `json:"toolMapping,omitempty"`
	LocalTools  map[string]string `json:"localTools,omitempty"`
	BuiltinFunc BuiltinFunc       `json:"-"`
	Source      ToolSource        `json:"source,omitempty"`
}

func (Tool) IsCommand

func (t Tool) IsCommand() bool

func (Tool) IsDaemon

func (t Tool) IsDaemon() bool

func (Tool) IsHTTP

func (t Tool) IsHTTP() bool

func (Tool) String

func (t Tool) String() string

type ToolSet

type ToolSet map[string]Tool

type ToolSource

type ToolSource struct {
	File   string `json:"file,omitempty"`
	LineNo int    `json:"lineNo,omitempty"`
}

func (ToolSource) String

func (t ToolSource) String() string

type Type

type Type []string

func (*Type) MarshalJSON

func (t *Type) MarshalJSON() ([]byte, error)

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL