ollama

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: CC0-1.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hallucinate added in v1.10.0

func Hallucinate[T valid.Interface](ctx context.Context, c *Client, opts HallucinateOpts) (*T, error)

Hallucinate prompts the model to hallucinate a "valid" JSON response to the given input.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string) *Client

func NewLocalClient

func NewLocalClient() *Client

func (*Client) Chat

func (*Client) Embeddings added in v1.10.0

func (c *Client) Embeddings(ctx context.Context, er *EmbedRequest) (*EmbedResponse, error)

func (*Client) Generate added in v1.11.0

func (c *Client) Generate(ctx context.Context, gr *GenerateRequest) (*GenerateResponse, error)

type CompleteRequest

type CompleteRequest struct {
	Model     string         `json:"model"`
	Messages  []Message      `json:"messages"`
	Format    *string        `json:"format,omitempty"`
	Template  *string        `json:"template,omitempty"`
	Stream    bool           `json:"stream"`
	Options   map[string]any `json:"options"`
	Tools     []Tool         `json:"tools"`
	KeepAlive string         `json:"keep_alive"`
}

type CompleteResponse

type CompleteResponse struct {
	Model              string    `json:"model"`
	CreatedAt          time.Time `json:"created_at"`
	Message            Message   `json:"message"`
	Done               bool      `json:"done"`
	TotalDuration      float64   `json:"total_duration"`
	LoadDuration       float64   `json:"load_duration"`
	PromptEvalCount    int64     `json:"prompt_eval_count"`
	PromptEvalDuration int64     `json:"prompt_eval_duration"`
	EvalCount          int64     `json:"eval_count"`
	EvalDuration       int64     `json:"eval_duration"`
}

type EmbedRequest added in v1.10.0

type EmbedRequest struct {
	Model     string         `json:"model"`
	Input     []string       `json:"input"`
	Truncate  bool           `json:"truncate"`
	Options   map[string]any `json:"options"`
	KeepAlive string         `json:"keep_alive"`
}

type EmbedResponse added in v1.10.0

type EmbedResponse struct {
	Embeddings [][]float64 `json:"embedding"`
}

type Function added in v1.11.0

type Function struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  Param  `json:"parameters"`
}

type GenerateRequest added in v1.11.0

type GenerateRequest struct {
	Model   string         `json:"model"`
	Prompt  string         `json:"prompt"`
	Images  [][]byte       `json:"images,omitempty"`
	Options map[string]any `json:"options"`

	Context   []int   `json:"context,omitempty"`
	Format    *string `json:"format,omitempty"`
	Template  *string `json:"template,omitempty"`
	System    *string `json:"system,omitempty"`
	Stream    bool    `json:"stream"`
	Raw       bool    `json:"raw"`
	KeepAlive string  `json:"keep_alive"`
}

type GenerateResponse added in v1.11.0

type GenerateResponse struct {
	Model              string    `json:"model"`
	CreatedAt          time.Time `json:"created_at"`
	Response           string    `json:"response"`
	Done               bool      `json:"done"`
	Context            []int     `json:"context"`
	TotalDuration      int64     `json:"total_duration"`
	LoadDuration       int64     `json:"load_duration"`
	PromptEvalCount    int       `json:"prompt_eval_count"`
	PromptEvalDuration int64     `json:"prompt_eval_duration"`
	EvalCount          int       `json:"eval_count"`
	EvalDuration       int64     `json:"eval_duration"`
}

type HallucinateOpts added in v1.10.0

type HallucinateOpts struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

HallucinateOpts contains the options for the Hallucinate function.

type Message

type Message struct {
	Content   string           `json:"content"`
	Role      string           `json:"role"`
	Images    [][]byte         `json:"images"`
	ToolCalls []ToolInvocation `json:"tool_calls"`
}

type Param added in v1.11.0

type Param struct {
	Type        string     `json:"type"`
	Description string     `json:"description,omitempty"`
	Enum        []string   `json:"enum,omitempty"`
	Properties  Properties `json:"properties"`
	Required    []string   `json:"required,omitempty"`
}

type Properties added in v1.11.0

type Properties map[string]Param

func (Properties) MarshalJSON added in v1.11.0

func (p Properties) MarshalJSON() ([]byte, error)

type Tool added in v1.11.0

type Tool struct {
	Type     string   `json:"type"` // "function"
	Function Function `json:"function"`
}

type ToolCall added in v1.11.0

type ToolCall struct {
	Name      string          `json:"name"`
	Arguments json.RawMessage `json:"arguments"`
}

type ToolInvocation added in v1.11.0

type ToolInvocation struct {
	Function ToolCall `json:"function"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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