Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSentenceEmpty is used to denote required sentences that needs to be summarized ErrSentenceEmpty = errors.New("you cannot summarize an empty string") // ErrUnsupportedSummarizerType is used to denote an summarization algorithm we do not support at the moment ErrUnsupportedSummarizerType = errors.New("unsupported summarizer type") )
var ErrInvalidLLMProvider = errors.New("not a valid LLMProvider")
var ErrInvalidType = errors.New("not a valid Type")
Functions ¶
This section is empty.
Types ¶
type AnthropicConfig ¶ added in v0.37.3
type AnthropicConfig struct {
// BetaHeader specifies the beta API features to enable
BetaHeader string `json:"betaHeader" koanf:"betaHeader"`
// LegacyTextCompletion enables legacy text completion API
LegacyTextCompletion bool `json:"legacyTextCompletion" koanf:"legacyTextCompletion"`
// BaseURL specifies the API endpoint
BaseURL string `json:"baseURL" koanf:"baseURL"`
GenericLLMConfig
}
AnthropicConfig contains Anthropic specific configuration
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client takes in texts, strips out all html tags and tries to summarize it to be human readable and short
func NewSummarizer ¶
NewSummarizer returns a configured client based on the provided configuration
type CloudflareConfig ¶ added in v0.37.3
type CloudflareConfig struct {
GenericLLMConfig
// AccountID specifies the Cloudflare account ID
AccountID string `json:"accountID" koanf:"accountID"`
// ServerURL specifies the API endpoint
ServerURL string `json:"serverURL" koanf:"serverURL"`
}
CloudflareConfig contains Cloudflare specific configuration
type Config ¶ added in v0.37.3
type Config struct {
// Type specifies the summarization algorithm to use
Type Type `json:"type" koanf:"type" default:"lexrank"`
// LLM contains configuration for large language model based summarization
LLM LLM `json:"llm" koanf:"llm"`
// MaximumSentences specifies the maximum number of sentences in the summary
MaximumSentences int `json:"maximumSentences" koanf:"maximumSentences" default:"10"`
}
Config holds configuration for the text summarization functionality
type GenericLLMConfig ¶ added in v0.37.3
type GenericLLMConfig struct {
// Model specifies the model name to use
Model string `json:"model" koanf:"model"`
// APIKey contains the authentication key for the service
APIKey string `json:"apiKey" koanf:"apiKey" sensitive:"true"`
}
GenericLLMConfig contains common and reusable fields for LLM providers
type LLM ¶ added in v0.37.3
type LLM struct {
// Provider specifies which LLM service to use
Provider LLMProvider `json:"provider" koanf:"provider" default:"none"`
// Anthropic contains configuration for Anthropic's API
Anthropic AnthropicConfig `json:"anthropic" koanf:"anthropic"`
// Cloudflare contains configuration for Cloudflare's API
Cloudflare CloudflareConfig `json:"cloudflare" koanf:"cloudflare"`
// OpenAI contains configuration for OpenAI's API
OpenAI OpenAIConfig `json:"openai" koanf:"openai"`
}
LLM contains configuration for multiple LLM providers
type LLMProvider ¶ added in v0.37.3
type LLMProvider string
LLMProvider defines supported LLM service providers ENUM(openai,anthropic,mistral,gemini,cloudflare,huggingface,ollama)
const ( // LLMProviderOpenai is a LLMProvider of type openai. LLMProviderOpenai LLMProvider = "openai" // LLMProviderAnthropic is a LLMProvider of type anthropic. LLMProviderAnthropic LLMProvider = "anthropic" // LLMProviderMistral is a LLMProvider of type mistral. LLMProviderMistral LLMProvider = "mistral" // LLMProviderGemini is a LLMProvider of type gemini. LLMProviderGemini LLMProvider = "gemini" // LLMProviderCloudflare is a LLMProvider of type cloudflare. LLMProviderCloudflare LLMProvider = "cloudflare" // LLMProviderHuggingface is a LLMProvider of type huggingface. LLMProviderHuggingface LLMProvider = "huggingface" // LLMProviderOllama is a LLMProvider of type ollama. LLMProviderOllama LLMProvider = "ollama" )
func ParseLLMProvider ¶ added in v0.37.3
func ParseLLMProvider(name string) (LLMProvider, error)
ParseLLMProvider attempts to convert a string to a LLMProvider.
func (LLMProvider) IsValid ¶ added in v0.37.3
func (x LLMProvider) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (LLMProvider) String ¶ added in v0.37.3
func (x LLMProvider) String() string
String implements the Stringer interface.
type OpenAIConfig ¶ added in v0.37.3
type OpenAIConfig struct {
GenericLLMConfig
// URL specifies the API endpoint
URL string `json:"url" koanf:"url"`
// OrganizationID specifies the OpenAI organization ID
OrganizationID string `json:"organizationID" koanf:"organizationID"`
}
OpenAIConfig contains OpenAI specific configuration
type Type ¶ added in v0.37.3
type Type string
Type defines the type of summarization algorithm ENUM(lexrank,llm)