Documentation
¶
Index ¶
- Constants
- func GenerateLingRequestID() string
- type AlibabaHandler
- func (h *AlibabaHandler) GetMaxMemoryMessages() int
- func (h *AlibabaHandler) Interrupt()
- func (h *AlibabaHandler) Provider() string
- func (h *AlibabaHandler) Query(text, model string) (string, error)
- func (h *AlibabaHandler) QueryStream(text string, options *QueryOptions, ...) (*QueryResponse, error)
- func (h *AlibabaHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
- func (h *AlibabaHandler) ResetMemory()
- func (h *AlibabaHandler) SetMaxMemoryMessages(n int)
- func (h *AlibabaHandler) SummarizeMemory(model string) (string, error)
- type AnthropicHandler
- func (h *AnthropicHandler) GetMaxMemoryMessages() int
- func (h *AnthropicHandler) Interrupt()
- func (h *AnthropicHandler) Provider() string
- func (h *AnthropicHandler) Query(text, model string) (string, error)
- func (h *AnthropicHandler) QueryStream(text string, options *QueryOptions, ...) (*QueryResponse, error)
- func (h *AnthropicHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
- func (h *AnthropicHandler) ResetMemory()
- func (h *AnthropicHandler) SetMaxMemoryMessages(n int)
- func (h *AnthropicHandler) SummarizeMemory(model string) (string, error)
- type CompletionTokensDetails
- type CozeHandler
- func (h *CozeHandler) GetMaxMemoryMessages() int
- func (h *CozeHandler) Interrupt()
- func (h *CozeHandler) Provider() string
- func (h *CozeHandler) Query(text, model string) (string, error)
- func (h *CozeHandler) QueryStream(text string, options *QueryOptions, ...) (*QueryResponse, error)
- func (h *CozeHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
- func (h *CozeHandler) ResetMemory()
- func (h *CozeHandler) SetMaxMemoryMessages(n int)
- func (h *CozeHandler) SummarizeMemory(model string) (string, error)
- type FewShotExample
- type LLMDetails
- type LLMHandler
- type LLMOptions
- type LLMProvider
- type LMStudioHandler
- func (h *LMStudioHandler) GetMaxMemoryMessages() int
- func (h *LMStudioHandler) Interrupt()
- func (h *LMStudioHandler) Provider() string
- func (h *LMStudioHandler) Query(text, model string) (string, error)
- func (h *LMStudioHandler) QueryStream(text string, options *QueryOptions, ...) (*QueryResponse, error)
- func (h *LMStudioHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
- func (h *LMStudioHandler) ResetMemory()
- func (h *LMStudioHandler) SetMaxMemoryMessages(n int)
- func (h *LMStudioHandler) SummarizeMemory(model string) (string, error)
- type OllamaHandler
- func (h *OllamaHandler) GetMaxMemoryMessages() int
- func (h *OllamaHandler) Interrupt()
- func (h *OllamaHandler) Provider() string
- func (h *OllamaHandler) Query(text, model string) (string, error)
- func (h *OllamaHandler) QueryStream(text string, options *QueryOptions, ...) (*QueryResponse, error)
- func (h *OllamaHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
- func (h *OllamaHandler) ResetMemory()
- func (h *OllamaHandler) SetMaxMemoryMessages(n int)
- func (h *OllamaHandler) SummarizeMemory(model string) (string, error)
- type OpenaiHandler
- func (oh *OpenaiHandler) GetMaxMemoryMessages() int
- func (oh *OpenaiHandler) Interrupt()
- func (oh *OpenaiHandler) Provider() string
- func (oh *OpenaiHandler) Query(text, model string) (string, error)
- func (oh *OpenaiHandler) QueryStream(text string, options *QueryOptions, ...) (*QueryResponse, error)
- func (oh *OpenaiHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
- func (oh *OpenaiHandler) ResetMemory()
- func (oh *OpenaiHandler) SetMaxMemoryMessages(n int)
- func (oh *OpenaiHandler) SummarizeMemory(model string) (string, error)
- type PromptTokensDetails
- type QueryChoice
- type QueryOptions
- type QueryResponse
- type TokenUsage
Constants ¶
View Source
const ( ProviderOpenAI = "openai" ProviderOllama = "ollama" ProviderAlibaba = "alibaba" ProviderAnthropic = "anthropic" ProviderLMStudio = "lmstudio" ProviderCoze = "coze" )
View Source
const ( LLM_OPENAI = "llm.openai" LLM_ANTHROPIC = "llm.anthropic" LLM_COZE = "llm.coze" LLM_OLLAMA = "llm.ollama" LLM_LMSTUDIO = "llm.lmstudio" LLM_ALIBABA = "llm.alibaba" )
View Source
const ( OutputFormatText = "text" OutputFormatJSON = "json" OutputFormatJSONObject = "json_object" OutputFormatJSONSchema = "json_schema" OutputFormatXML = "xml" OutputFormatHTML = "html" OutputFormatSQL = "sql" )
Variables ¶
This section is empty.
Functions ¶
func GenerateLingRequestID ¶
func GenerateLingRequestID() string
Types ¶
type AlibabaHandler ¶
type AlibabaHandler struct {
// contains filtered or unexported fields
}
func NewAlibabaHandler ¶
func NewAlibabaHandler(ctx context.Context, llmOptions *LLMOptions) (*AlibabaHandler, error)
func (*AlibabaHandler) GetMaxMemoryMessages ¶
func (h *AlibabaHandler) GetMaxMemoryMessages() int
func (*AlibabaHandler) Interrupt ¶
func (h *AlibabaHandler) Interrupt()
func (*AlibabaHandler) Provider ¶
func (h *AlibabaHandler) Provider() string
func (*AlibabaHandler) QueryStream ¶
func (h *AlibabaHandler) QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
func (*AlibabaHandler) QueryWithOptions ¶
func (h *AlibabaHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
func (*AlibabaHandler) ResetMemory ¶
func (h *AlibabaHandler) ResetMemory()
func (*AlibabaHandler) SetMaxMemoryMessages ¶
func (h *AlibabaHandler) SetMaxMemoryMessages(n int)
func (*AlibabaHandler) SummarizeMemory ¶
func (h *AlibabaHandler) SummarizeMemory(model string) (string, error)
type AnthropicHandler ¶
type AnthropicHandler struct {
// contains filtered or unexported fields
}
func NewAnthropicHandler ¶
func NewAnthropicHandler(ctx context.Context, llmOptions *LLMOptions) (*AnthropicHandler, error)
func (*AnthropicHandler) GetMaxMemoryMessages ¶
func (h *AnthropicHandler) GetMaxMemoryMessages() int
func (*AnthropicHandler) Interrupt ¶
func (h *AnthropicHandler) Interrupt()
func (*AnthropicHandler) Provider ¶
func (h *AnthropicHandler) Provider() string
func (*AnthropicHandler) Query ¶
func (h *AnthropicHandler) Query(text, model string) (string, error)
func (*AnthropicHandler) QueryStream ¶
func (h *AnthropicHandler) QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
func (*AnthropicHandler) QueryWithOptions ¶
func (h *AnthropicHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
func (*AnthropicHandler) ResetMemory ¶
func (h *AnthropicHandler) ResetMemory()
func (*AnthropicHandler) SetMaxMemoryMessages ¶
func (h *AnthropicHandler) SetMaxMemoryMessages(n int)
func (*AnthropicHandler) SummarizeMemory ¶
func (h *AnthropicHandler) SummarizeMemory(model string) (string, error)
type CompletionTokensDetails ¶
type CozeHandler ¶
type CozeHandler struct {
// contains filtered or unexported fields
}
func NewCozeHandler ¶
func NewCozeHandler(ctx context.Context, llmOptions *LLMOptions) (*CozeHandler, error)
func (*CozeHandler) GetMaxMemoryMessages ¶
func (h *CozeHandler) GetMaxMemoryMessages() int
func (*CozeHandler) Interrupt ¶
func (h *CozeHandler) Interrupt()
func (*CozeHandler) Provider ¶
func (h *CozeHandler) Provider() string
func (*CozeHandler) QueryStream ¶
func (h *CozeHandler) QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
func (*CozeHandler) QueryWithOptions ¶
func (h *CozeHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
func (*CozeHandler) ResetMemory ¶
func (h *CozeHandler) ResetMemory()
func (*CozeHandler) SetMaxMemoryMessages ¶
func (h *CozeHandler) SetMaxMemoryMessages(n int)
func (*CozeHandler) SummarizeMemory ¶
func (h *CozeHandler) SummarizeMemory(model string) (string, error)
type FewShotExample ¶
type LLMDetails ¶
type LLMDetails struct {
RequestID string
Provider string
BaseURL string
Model string
Input string
SystemPrompt string
N int
MaxTokens int
EstimatedMaxOutputChars int
FilterEmoji bool
RequestedOutputFormat string
AppliedResponseFormat string
ResponseFormatApplied bool
ResponseID string
Object string
Created int64
SystemFingerprint string
PromptFilterResultsJSON string
ServiceTierJSON string
ChoicesCount int
Choices []QueryChoice
Usage *TokenUsage
UsageRawJSON string
ChoicesRawJSON string
RawResponseJSON string
}
type LLMHandler ¶
type LLMHandler interface {
Query(text, model string) (string, error)
QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
Provider() string
Interrupt()
ResetMemory()
SummarizeMemory(model string) (string, error)
SetMaxMemoryMessages(n int)
GetMaxMemoryMessages() int
}
LLMHandler common llm hanlder interface
func NewLLMProvider ¶
func NewLLMProvider(ctx context.Context, provider, apiKey, apiURL, systemPrompt string) (LLMHandler, error)
NewLLMProvider provides a SoulNexus-like factory signature for Ling.
func NewProviderHandler ¶
func NewProviderHandler(ctx context.Context, provider string, llmOptions *LLMOptions) (LLMHandler, error)
NewProviderHandler creates an LLM handler by provider type. Note: in Ling, non-OpenAI providers currently use OpenAI-compatible chat API shape.
type LLMOptions ¶
type LMStudioHandler ¶
type LMStudioHandler struct {
// contains filtered or unexported fields
}
func NewLMStudioHandler ¶
func NewLMStudioHandler(ctx context.Context, llmOptions *LLMOptions) (*LMStudioHandler, error)
func (*LMStudioHandler) GetMaxMemoryMessages ¶
func (h *LMStudioHandler) GetMaxMemoryMessages() int
func (*LMStudioHandler) Interrupt ¶
func (h *LMStudioHandler) Interrupt()
func (*LMStudioHandler) Provider ¶
func (h *LMStudioHandler) Provider() string
func (*LMStudioHandler) QueryStream ¶
func (h *LMStudioHandler) QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
func (*LMStudioHandler) QueryWithOptions ¶
func (h *LMStudioHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
func (*LMStudioHandler) ResetMemory ¶
func (h *LMStudioHandler) ResetMemory()
func (*LMStudioHandler) SetMaxMemoryMessages ¶
func (h *LMStudioHandler) SetMaxMemoryMessages(n int)
func (*LMStudioHandler) SummarizeMemory ¶
func (h *LMStudioHandler) SummarizeMemory(model string) (string, error)
type OllamaHandler ¶
type OllamaHandler struct {
// contains filtered or unexported fields
}
func NewOllamaHandler ¶
func NewOllamaHandler(ctx context.Context, llmOptions *LLMOptions) (*OllamaHandler, error)
func (*OllamaHandler) GetMaxMemoryMessages ¶
func (h *OllamaHandler) GetMaxMemoryMessages() int
func (*OllamaHandler) Interrupt ¶
func (h *OllamaHandler) Interrupt()
func (*OllamaHandler) Provider ¶
func (h *OllamaHandler) Provider() string
func (*OllamaHandler) QueryStream ¶
func (h *OllamaHandler) QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
func (*OllamaHandler) QueryWithOptions ¶
func (h *OllamaHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
func (*OllamaHandler) ResetMemory ¶
func (h *OllamaHandler) ResetMemory()
func (*OllamaHandler) SetMaxMemoryMessages ¶
func (h *OllamaHandler) SetMaxMemoryMessages(n int)
func (*OllamaHandler) SummarizeMemory ¶
func (h *OllamaHandler) SummarizeMemory(model string) (string, error)
type OpenaiHandler ¶
type OpenaiHandler struct {
// contains filtered or unexported fields
}
func NewOpenaiHandler ¶
func NewOpenaiHandler(ctx context.Context, llmOptions *LLMOptions) (*OpenaiHandler, error)
func (*OpenaiHandler) GetMaxMemoryMessages ¶
func (oh *OpenaiHandler) GetMaxMemoryMessages() int
func (*OpenaiHandler) Interrupt ¶
func (oh *OpenaiHandler) Interrupt()
func (*OpenaiHandler) Provider ¶
func (oh *OpenaiHandler) Provider() string
func (*OpenaiHandler) QueryStream ¶
func (oh *OpenaiHandler) QueryStream(text string, options *QueryOptions, callback func(segment string, isComplete bool) error) (*QueryResponse, error)
func (*OpenaiHandler) QueryWithOptions ¶
func (oh *OpenaiHandler) QueryWithOptions(text string, options *QueryOptions) (*QueryResponse, error)
func (*OpenaiHandler) ResetMemory ¶
func (oh *OpenaiHandler) ResetMemory()
func (*OpenaiHandler) SetMaxMemoryMessages ¶
func (oh *OpenaiHandler) SetMaxMemoryMessages(n int)
func (*OpenaiHandler) SummarizeMemory ¶
func (oh *OpenaiHandler) SummarizeMemory(model string) (string, error)
type PromptTokensDetails ¶
type QueryChoice ¶
type QueryOptions ¶
type QueryOptions struct {
Model string
N int
MaxTokens int
Temperature float32
TopP float32
LogitBias map[string]int
FilterEmoji bool
EnableJSONOutput bool
OutputFormat string
// EmotionalTone, when true, appends a short instruction so replies read warmer and more human (still factual).
EmotionalTone bool
// contains filtered or unexported fields
}
type QueryResponse ¶
type QueryResponse struct {
Provider string
Model string
Choices []QueryChoice
Usage *TokenUsage
}
type TokenUsage ¶
type TokenUsage struct {
PromptTokens int
CompletionTokens int
TotalTokens int
PromptTokensDetails *PromptTokensDetails
CompletionTokensDetails *CompletionTokensDetails
}
Click to show internal directories.
Click to hide internal directories.