schema

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content added in v1.0.2

type Content struct {
	Id     string         `json:"id,omitempty"`
	Type   string         `json:"type,width:4"`
	Text   string         `json:"text,omitempty,wrap,width:60"`
	Source *contentSource `json:"source,omitempty"`

	ToolId string `json:"tool_use_id,omitempty"`
	Result string `json:"content,omitempty"`
	// contains filtered or unexported fields
}

Message Content

func Image added in v1.0.2

func Image(r io.Reader) (*Content, error)

Return a new content object of type image, from a io.Reader

func ImageData added in v1.0.2

func ImageData(path string) (*Content, error)

Return a new content object of type image, from a file

func Text added in v1.0.2

func Text(v string) *Content

Return a new content object of type text

func ToolResult added in v1.0.3

func ToolResult(id string, result string) *Content

Return a tool result

func (Content) GetString added in v1.0.3

func (c Content) GetString(name, input string) (string, bool)

Return an input parameter as a string, returns false if the name is incorrect or the input doesn't exist

func (Content) String added in v1.0.2

func (c Content) String() string

type Embedding

type Embedding struct {
	Embedding []float64 `json:"embedding"`
	Index     int       `json:"index"`
}

An embedding object

func (Embedding) CosineDistance

func (e Embedding) CosineDistance(other Embedding) float64

type Embeddings

type Embeddings struct {
	Id    string      `json:"id"`
	Data  []Embedding `json:"data"`
	Model string      `json:"model"`
	Usage struct {
		PromptTokerns int `json:"prompt_tokens"`
		TotalTokens   int `json:"total_tokens"`
	} `json:"usage"`
}

An set of created embeddings

type Message

type Message struct {
	// user or assistant
	Role string `json:"role"`

	// Message Id
	Id string `json:"id,omitempty"`

	// Model
	Model string `json:"model,omitempty"`

	// Content can be a string, array of strings, content
	// object or an array of content objects
	Content any `json:"content,omitempty"`
}

A chat completion message

func NewMessage added in v1.0.2

func NewMessage(role string, content ...any) *Message

Create a new message, with optional content

func (*Message) Add added in v1.0.2

func (m *Message) Add(content ...any) *Message

Append content to the message

func (*Message) IsValid added in v1.0.2

func (m *Message) IsValid() bool

func (Message) String added in v1.0.2

func (m Message) String() string

type MessageChoice

type MessageChoice struct {
	Message      `json:"message"`
	Index        int    `json:"index"`
	FinishReason string `json:"finish_reason"`
}

One choice of chat completion messages

type Model

type Model struct {
	Id      string `json:"id"`
	Created int64  `json:"created,omitempty"`
	Owner   string `json:"owned_by,omitempty"`
}

A model object

type Tool added in v1.0.2

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Parameters  *toolParameters `json:"input_schema,omitempty"`
}

A tool function

func NewTool added in v1.0.2

func NewTool(name, description string) *Tool

func (*Tool) AddParameter added in v1.0.2

func (t *Tool) AddParameter(name, description string, required bool) error

func (Tool) String added in v1.0.2

func (t Tool) String() string

Jump to

Keyboard shortcuts

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