llm

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	Model    string  `json:"model"`
	Message  Message `json:"message"` // For Chat Completion
	Done     bool    `json:"done"`
	Response string  `json:"response"` // For "Simple" Completion
	Context  []int   `json:"context"`  // For "Simple" Completion

	CreatedAt          time.Time `json:"created_at"`
	TotalDuration      int64     `json:"total_duration"`
	LoadDuration       int       `json:"load_duration"`
	PromptEvalCount    int       `json:"prompt_eval_count"`
	PromptEvalDuration int       `json:"prompt_eval_duration"`
	EvalCount          int       `json:"eval_count"`
	EvalDuration       int64     `json:"eval_duration"`
}

func (*Answer) ToJsonString added in v0.1.0

func (answer *Answer) ToJsonString() string

type Function added in v0.0.6

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

type FunctionTool added in v0.1.6

type FunctionTool struct {
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments"` // used for the ToolCalls list
}

func (*FunctionTool) ToJSONString added in v0.1.6

func (ft *FunctionTool) ToJSONString() (string, error)

type LLM

type LLM struct {
	Name string `json:"name"`
	Url  string `json:"url"`
}

type Message

type Message struct {
	Role      string `json:"role"`
	Content   string `json:"content"`
	ToolCalls []struct {
		Function FunctionTool `json:"function"`
	} `json:"tool_calls"`
}

func (*Message) FirstToolCallToJSONString added in v0.1.6

func (m *Message) FirstToolCallToJSONString() (string, error)

func (*Message) ToolCallsToJSONString added in v0.0.7

func (m *Message) ToolCallsToJSONString() (string, error)

type MessageRecord added in v0.0.3

type MessageRecord struct {
	Id      string `json:"id"`
	Role    string `json:"role"`
	Content string `json:"content"`
}

type ModelInformation added in v0.0.7

type ModelInformation struct {
	Modelfile  string `json:"modelfile"`
	Parameters string `json:"parameters"`
	Template   string `json:"template"`
	Details    struct {
		Format            string   `json:"format"`
		Family            string   `json:"family"`
		Families          []string `json:"families"`
		ParameterSize     string   `json:"parameter_size"`
		QuantizationLevel string   `json:"quantization_level"`
	} `json:"details"`
}

func ShowModelInformation added in v0.0.7

func ShowModelInformation(url, model string) (ModelInformation, int, error)

ShowModelInformation retrieves information about a model from the specified URL.

Parameters: - url: the base URL of the API. - model: the name of the model to retrieve information for.

Returns: - ModelInformation: the information about the model. - int: the HTTP status code of the response. - error: an error if the request fails.

type Options

type Options struct {
	RepeatLastN   int      `json:"repeat_last_n,omitempty"`
	Temperature   float64  `json:"temperature,omitempty"`
	Seed          int      `json:"seed,omitempty"`
	RepeatPenalty float64  `json:"repeat_penalty,omitempty"`
	Stop          []string `json:"stop,omitempty"`

	NumKeep          int     `json:"num_keep,omitempty"`
	NumPredict       int     `json:"num_predict,omitempty"`
	TopK             int     `json:"top_k,omitempty"`
	TopP             float64 `json:"top_p,omitempty"`
	TFSZ             float64 `json:"tfs_z,omitempty"`
	TypicalP         float64 `json:"typical_p,omitempty"`
	PresencePenalty  float64 `json:"presence_penalty,omitempty"`
	FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
	Mirostat         int     `json:"mirostat,omitempty"`
	MirostatTau      float64 `json:"mirostat_tau,omitempty"`
	MirostatEta      float64 `json:"mirostat_eta,omitempty"`
	PenalizeNewline  bool    `json:"penalize_newline,omitempty"`

	Verbose bool
}

type Parameters added in v0.0.6

type Parameters struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties"`
	Required   []string            `json:"required"`
}

type Property added in v0.0.6

type Property struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

type PullResult added in v0.0.7

type PullResult struct {
	Status string `json:"status"`
}

func PullModel added in v0.0.7

func PullModel(url, model string) (PullResult, int, error)

PullModel sends a POST request to the specified URL to pull a model with the given name.

Parameters: - url: The URL to send the request to. - model: The name of the model to pull.

Returns: - PullResult: The result of the pull operation. - int: The HTTP status code of the response. - error: An error if the request fails.

type Query

type Query struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"` // For Chat Completion
	Options  Options   `json:"options"`
	Stream   bool      `json:"stream"`
	Prompt   string    `json:"prompt"`  // For "Simple" Completion
	Context  []int     `json:"context"` // For "Simple" Completion
	Tools    []Tool    `json:"tools"`

	Format    string `json:"format,omitempty"` // https://github.com/ollama/ollama/blob/main/docs/api.md#request-json-mode
	KeepAlive bool   `json:"keep_alive,omitempty"`
	Raw       bool   `json:"raw,omitempty"`
	System    string `json:"system,omitempty"`
	Template  string `json:"template,omitempty"`

	TokenHeaderName  string
	TokenHeaderValue string
}

https://github.com/ollama/ollama/blob/main/docs/api.md#parameters

func (*Query) ToJsonString added in v0.1.0

func (query *Query) ToJsonString() string

type Query4Embedding added in v0.0.1

type Query4Embedding struct {
	Prompt string `json:"prompt"`
	Model  string `json:"model"`

	TokenHeaderName  string
	TokenHeaderValue string
}

type Tool added in v0.0.6

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

type VectorRecord added in v0.0.1

type VectorRecord struct {
	Id             string    `json:"id"`
	Prompt         string    `json:"prompt"`
	Embedding      []float64 `json:"embedding"`
	CosineDistance float64
	Score          float64 // ElasticSearch

	Reference string `json:"reference"`
	MetaData  string `json:"metaData"`
	Text      string `json:"text"`
}

Jump to

Keyboard shortcuts

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