Documentation ¶
Index ¶
- Constants
- type Chatbot
- func (c *Chatbot) AddChatSessionCtx(userID string, content string, role, aiName string)
- func (c *Chatbot) ClaudeRequest(cache *chatResponseCache, userID string, input string) (string, error)
- func (c *Chatbot) GeminiRequest(cache *chatResponseCache, userID string, input string) (string, error)
- func (c *Chatbot) GetChatMessageFromDB(userID, aiName string) []chatMessage
- func (c *Chatbot) GetChatSessionCtx(userID string, ctxs []openai.ChatMessage) []openai.ChatMessage
- func (c *Chatbot) GetClaudeChatSessionCtx(userID string, ctxs []claude.Message) []claude.Message
- func (c *Chatbot) GetGeminiChatSessionCtx(userID string) []*genai.Content
- func (c *Chatbot) GetResponse(userID string, input string) (string, error)
- func (c *Chatbot) OpenAIRequest(cache *chatResponseCache, userID string, input string) (string, error)
- func (c *Chatbot) RegsiterMessagePublish(publisher func(string, string) error)
- func (c *Chatbot) WaitChatResponse(userID string)
- type ClaudeConfig
- type Config
- type GeminiConfig
- type OpenAIConfig
- type RedisConfig
Constants ¶
View Source
const ( ChatRoleUser = "user" ChatRoleAI = "ai" AIName_OpenAI = "openai" AIName_Gemini = "gemini" AIName_Claude = "claude" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chatbot ¶
type Chatbot struct {
// contains filtered or unexported fields
}
Chatbot 是聊天机器人结构体
func MustChatbot ¶
func MustChatbot() *Chatbot
func (*Chatbot) AddChatSessionCtx ¶
func (*Chatbot) ClaudeRequest ¶
func (*Chatbot) GeminiRequest ¶
func (*Chatbot) GetChatMessageFromDB ¶
func (*Chatbot) GetChatSessionCtx ¶
func (c *Chatbot) GetChatSessionCtx(userID string, ctxs []openai.ChatMessage) []openai.ChatMessage
func (*Chatbot) GetClaudeChatSessionCtx ¶
func (*Chatbot) GetGeminiChatSessionCtx ¶
func (*Chatbot) GetResponse ¶
GetResponse 调用聊天机器人API获取响应
func (*Chatbot) OpenAIRequest ¶
func (*Chatbot) RegsiterMessagePublish ¶
注册聊天消息的异步推送回调 其实这里比较好的设计应该是调用ChatBot的调用方,在发起聊天请求中注册一下异步推送的回调,这样就可以支持不同的pusher了
func (*Chatbot) WaitChatResponse ¶
type ClaudeConfig ¶
claude配置
type Config ¶
type Config struct { OpenAI OpenAIConfig `json:"open_ai"` Gemini GeminiConfig `json:"gemini"` Claude ClaudeConfig `json:"claude"` Redis RedisConfig `json:"redis"` }
type GeminiConfig ¶
gemini配置
type OpenAIConfig ¶
openai配置
Click to show internal directories.
Click to hide internal directories.