Documentation ¶
Index ¶
- Constants
- type ChatMessage
- type Chatglm
- func (llm *Chatglm) Chat(messages []*ChatMessage, opts ...GenerationOption) (string, error)
- func (llm *Chatglm) Embeddings(text string, opts ...GenerationOption) ([]int, error)
- func (llm *Chatglm) Free()
- func (llm *Chatglm) Generate(prompt string, opts ...GenerationOption) (string, error)
- func (llm *Chatglm) ModelType() string
- func (llm *Chatglm) StreamChat(messages []*ChatMessage, opts ...GenerationOption) (string, error)
- func (llm *Chatglm) StreamGenerate(prompt string, opts ...GenerationOption) (string, error)
- type CodeMessage
- type FunctionMessage
- type GenerationOption
- func SetDoSample(doSample bool) GenerationOption
- func SetMaxContextLength(maxContextLength int) GenerationOption
- func SetMaxLength(maxLength int) GenerationOption
- func SetNumThreads(numThreads int) GenerationOption
- func SetRepetitionPenalty(repetitionPenalty float32) GenerationOption
- func SetStreamCallback(callback func(string) bool) GenerationOption
- func SetTemperature(temperature float32) GenerationOption
- func SetTopK(topK int) GenerationOption
- func SetTopP(topP float32) GenerationOption
- type GenerationOptions
- type ToolCallMessage
Constants ¶
View Source
const ( RoleUser = "user" RoleAssistant = "assistant" RoleSystem = "system" RoleObservation = "observation" TypeFunction = "function" TypeCode = "code" DELIMITER = "<|delimiter|>" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessage ¶ added in v0.1.1
type ChatMessage struct { Role string Content string ToolCalls []*ToolCallMessage }
func NewAssistantMsg ¶ added in v0.1.1
func NewAssistantMsg(input string, modelType string) *ChatMessage
func NewObservationMsg ¶ added in v0.1.1
func NewObservationMsg(content string) *ChatMessage
func NewSystemMsg ¶ added in v0.1.1
func NewSystemMsg(content string) *ChatMessage
func NewUserMsg ¶ added in v0.1.1
func NewUserMsg(content string) *ChatMessage
type Chatglm ¶
type Chatglm struct {
// contains filtered or unexported fields
}
func (*Chatglm) Chat ¶
func (llm *Chatglm) Chat(messages []*ChatMessage, opts ...GenerationOption) (string, error)
Chat by history [synchronous]
func (*Chatglm) Embeddings ¶
func (llm *Chatglm) Embeddings(text string, opts ...GenerationOption) ([]int, error)
Embeddings get text input_ids,
func (*Chatglm) Generate ¶
func (llm *Chatglm) Generate(prompt string, opts ...GenerationOption) (string, error)
Generate by prompt [synchronous]
func (*Chatglm) StreamChat ¶
func (llm *Chatglm) StreamChat(messages []*ChatMessage, opts ...GenerationOption) (string, error)
StreamChat chat with stream output by StreamCallback
func (*Chatglm) StreamGenerate ¶
func (llm *Chatglm) StreamGenerate(prompt string, opts ...GenerationOption) (string, error)
StreamGenerate with stream output by StreamCallback
type CodeMessage ¶ added in v0.1.1
type CodeMessage struct {
Input string
}
type FunctionMessage ¶ added in v0.1.1
type GenerationOption ¶
type GenerationOption func(g *GenerationOptions)
func SetDoSample ¶
func SetDoSample(doSample bool) GenerationOption
func SetMaxContextLength ¶
func SetMaxContextLength(maxContextLength int) GenerationOption
func SetMaxLength ¶
func SetMaxLength(maxLength int) GenerationOption
func SetNumThreads ¶
func SetNumThreads(numThreads int) GenerationOption
func SetRepetitionPenalty ¶
func SetRepetitionPenalty(repetitionPenalty float32) GenerationOption
func SetStreamCallback ¶
func SetStreamCallback(callback func(string) bool) GenerationOption
func SetTemperature ¶
func SetTemperature(temperature float32) GenerationOption
func SetTopK ¶
func SetTopK(topK int) GenerationOption
func SetTopP ¶
func SetTopP(topP float32) GenerationOption
type GenerationOptions ¶
type GenerationOptions struct { MaxLength int MaxContextLength int DoSample bool TopK int TopP float32 Temperature float32 RepetitionPenalty float32 NumThreads int StreamCallback func(string) bool }
var DefaultGenerationOptions GenerationOptions = GenerationOptions{ MaxLength: 2048, MaxContextLength: 512, DoSample: true, TopK: 0, TopP: 0.7, Temperature: 0.95, RepetitionPenalty: 1.0, NumThreads: 0, StreamCallback: nil, }
func NewGenerationOptions ¶
func NewGenerationOptions(opts ...GenerationOption) *GenerationOptions
type ToolCallMessage ¶ added in v0.1.1
type ToolCallMessage struct { Type string Function *FunctionMessage Code *CodeMessage }
Click to show internal directories.
Click to hide internal directories.