Documentation ¶
Index ¶
- func Hallucinate[T valid.Interface](ctx context.Context, c *Client, opts HallucinateOpts) (*T, error)
- type Client
- type CompleteRequest
- type CompleteResponse
- type EmbedRequest
- type EmbedResponse
- type Function
- type GenerateRequest
- type GenerateResponse
- type HallucinateOpts
- type Message
- type Param
- type Properties
- type Tool
- type ToolCall
- type ToolInvocation
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 NewLocalClient ¶
func NewLocalClient() *Client
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, inp *CompleteRequest) (*CompleteResponse, error)
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 EmbedResponse ¶ added in v1.10.0
type EmbedResponse struct {
Embeddings [][]float64 `json:"embedding"`
}
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
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
func (Properties) MarshalJSON ¶ added in v1.11.0
func (p Properties) MarshalJSON() ([]byte, error)
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"`
}
Click to show internal directories.
Click to hide internal directories.