Versions in this module Expand all Collapse all v0 v0.2.2 Apr 12, 2024 v0.2.1 Mar 24, 2024 Changes in this version type Option + func WithCallback(callbacksHandler callbacks.Handler) Option type ZhiPuAILLM + func (z *ZhiPuAILLM) GenerateContent(ctx context.Context, messages []langchainllm.MessageContent, ...) (*langchainllm.ContentResponse, error) v0.2.0 Feb 28, 2024 Changes in this version + type Option func(*options) + func WithRetryTimes(retryTimes int) Option type ZhiPuAILLM + func NewZhiPuAILLM(apiKey string, opts ...Option) *ZhiPuAILLM v0.1.0 Dec 29, 2023 Changes in this version + const APITokenTTLSeconds + const CacheTTLSeconds + const CodeConcurrencyHigh + const CodeTimesHigh + const CodefrequencyHigh + const RetryLimit + const ZhipuaiModelAPIURL + const ZhipuaiModelDefaultTimeout + var ErrEmptyPrompt = errors.New("empty prompt") + var ErrEmptyResponse = errors.New("no response") + func BuildAPIURL(model string, method Method) string + func GenerateToken(apikey string, expSeconds int64) (string, error) + func Stream(apiURL, token string, params ModelParams, timeout time.Duration, ...) error + func ValidateModelParams(params ModelParams) error + type Choice struct + Content string + Role string + type Data struct + Choices []Choice + RequestID string + TaskID string + TaskStatus string + Usage Usage + type EmbeddingData struct + Embedding []float32 + RequestID string + TaskID string + TaskStatus string + Usage Usage + type EmbeddingResponse struct + Code int + Data *EmbeddingData + Msg string + Success bool + func EmbeddingPost(apiURL, token string, text EmbeddingText, timeout time.Duration) (*EmbeddingResponse, error) + func (embeddingResp *EmbeddingResponse) Bytes() []byte + func (embeddingResp *EmbeddingResponse) String() string + func (embeddingResp *EmbeddingResponse) Type() llms.LLMType + func (embeddingResp *EmbeddingResponse) Unmarshall(bytes []byte) error + type EmbeddingText struct + Prompt string + RequestID string + type Method string + const ZhiPuAIAsyncGet + const ZhiPuAIAsyncInvoke + const ZhiPuAIInvoke + const ZhiPuAISSEInvoke + type ModelParams struct + Incremental bool + Method Method + Model string + Prompt []Prompt + TaskID string + Temperature float32 + TopP float32 + func DefaultModelParams() ModelParams + func MergeParams(a, b ModelParams) ModelParams + func (in *ModelParams) DeepCopy() *ModelParams + func (in *ModelParams) DeepCopyInto(out *ModelParams) + func (params *ModelParams) Marshal() []byte + func (params *ModelParams) Unmarshal(bytes []byte) error + type Prompt struct + Content string + Role Role + func (in *Prompt) DeepCopy() *Prompt + func (in *Prompt) DeepCopyInto(out *Prompt) + type Response struct + Code int + Data *Data + Msg string + Success bool + func Get(apiURL, token string, timeout time.Duration) (*Response, error) + func Post(apiURL, token string, params ModelParams, timeout time.Duration) (*Response, error) + func (response *Response) Bytes() []byte + func (response *Response) String() string + func (response *Response) Type() llms.LLMType + func (response *Response) Unmarshal(bytes []byte) error + type Role string + const Assistant + const User + type SSEClient struct + EncodingBase64 bool + LastEventID atomic.Value + func NewSSEClient() *SSEClient + func (c *SSEClient) Events(resp *http.Response) (<-chan *sse.Event, <-chan error) + type Usage struct + TotalTokens int + type ZhiPuAI struct + func NewZhiPuAI(apiKey string) *ZhiPuAI + func (z *ZhiPuAI) AsyncInvoke(params ModelParams) (*Response, error) + func (z *ZhiPuAI) Call(data []byte) (llms.Response, error) + func (z *ZhiPuAI) CreateEmbedding(ctx context.Context, inputTexts []string) ([][]float32, error) + func (z *ZhiPuAI) Embedding(text EmbeddingText) (*EmbeddingResponse, error) + func (z *ZhiPuAI) Get(params ModelParams) (*Response, error) + func (z *ZhiPuAI) Invoke(params ModelParams) (*Response, error) + func (z *ZhiPuAI) SSEInvoke(params ModelParams, handler func(*sse.Event)) error + func (z *ZhiPuAI) Validate(ctx context.Context, options ...langchainllms.CallOption) (llms.Response, error) + func (z ZhiPuAI) Type() llms.LLMType + type ZhiPuAILLM struct + RetryTimes int + func (z *ZhiPuAILLM) Call(ctx context.Context, messages []schema.ChatMessage, ...) (*schema.AIChatMessage, error) + func (z *ZhiPuAILLM) Generate(ctx context.Context, messageSets [][]schema.ChatMessage, ...) ([]*langchainllm.Generation, error) + func (z *ZhiPuAILLM) GeneratePrompt(ctx context.Context, promptValues []schema.PromptValue, ...) (langchainllm.LLMResult, error) + func (z *ZhiPuAILLM) GetNumTokens(text string) int