Documentation ¶
Index ¶
- Constants
- Variables
- func InitLogger(logLevel, logFile string)
- func PrintlnQrcodeUrl(uuid string)
- func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- type ChatCompletionMessage
- type ChatCompletionMessages
- type ChatContext
- func (u *ChatContext) AppendMessage(key string, value *ChatCompletionMessage)
- func (u *ChatContext) Clear(key string)
- func (u *ChatContext) ClearAll()
- func (u *ChatContext) GetMessages(senderName string) []openai.ChatCompletionMessage
- func (u *ChatContext) GetString(key string) string
- func (u *ChatContext) GetTimestampMessages(senderName string) ChatCompletionMessages
- func (u *ChatContext) SetDefaultMessage(key string)
- type ChatGptConf
- func (i *ChatGptConf) AddGroupNameWhiteList(name string)
- func (i *ChatGptConf) GetDefaultPrompt() openai.ChatCompletionMessage
- func (i *ChatGptConf) MatchGroupChatMentionPrefix(context string) bool
- func (i *ChatGptConf) MatchGroupName(groupName string) bool
- func (i *ChatGptConf) RemoveGroupNameWhiteList(name string)
- func (i *ChatGptConf) SetDefaultPrompt(value string)
- type ConfHelper
- func (i *ConfHelper) ConversationMaxTokens() int
- func (i *ConfHelper) ConversationTimeout() int
- func (i *ConfHelper) GetConf() *ChatGptConf
- func (i *ConfHelper) LoadJsonConf() (conf *ChatGptConf, err error)
- func (i *ConfHelper) MatchGroupFilter(msg *openwechat.Message) (bool, string, error)
- func (i *ConfHelper) SaveJsonConf(conf *ChatGptConf) error
- type MessageHandler
Constants ¶
View Source
const TimeFormat = "2006-01-02 15:04:05"
Variables ¶
View Source
var ChatGPTCommand = &cobra.Command{ Use: "start", Short: "启动chatgpt", Long: fmt.Sprintf(""), Run: processMessage, }
View Source
var Logger *zap.Logger
Functions ¶
func PrintlnQrcodeUrl ¶
func PrintlnQrcodeUrl(uuid string)
func TimeEncoder ¶
func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
TimeEncoder 序列化时间
Types ¶
type ChatCompletionMessage ¶
type ChatCompletionMessage struct { openai.ChatCompletionMessage Timestamp uint64 }
func (*ChatCompletionMessage) FillTimestamp ¶
func (c *ChatCompletionMessage) FillTimestamp()
FillTimestamp 填充时间戳
func (*ChatCompletionMessage) IsExpired ¶
func (i *ChatCompletionMessage) IsExpired() bool
IsExpired 判断消息是否过期
type ChatCompletionMessages ¶
type ChatCompletionMessages []*ChatCompletionMessage
func (*ChatCompletionMessages) GetValidChatCompletionMessages ¶
func (c *ChatCompletionMessages) GetValidChatCompletionMessages() []openai.ChatCompletionMessage
GetValidChatCompletionMessages 获取有效时间范围内的聊天消息
func (*ChatCompletionMessages) GetValidMessages ¶
func (c *ChatCompletionMessages) GetValidMessages() ChatCompletionMessages
GetValidMessages 获取有效时间范围内的聊天消息
func (*ChatCompletionMessages) RemoveSecondItem ¶
func (c *ChatCompletionMessages) RemoveSecondItem()
type ChatContext ¶
func (*ChatContext) AppendMessage ¶
func (u *ChatContext) AppendMessage(key string, value *ChatCompletionMessage)
AppendMessage 追加消息
func (*ChatContext) GetMessages ¶
func (u *ChatContext) GetMessages(senderName string) []openai.ChatCompletionMessage
GetMessages 获取消息
func (*ChatContext) GetString ¶
func (u *ChatContext) GetString(key string) string
func (*ChatContext) GetTimestampMessages ¶
func (u *ChatContext) GetTimestampMessages(senderName string) ChatCompletionMessages
GetTimestampMessages 获取消息
func (*ChatContext) SetDefaultMessage ¶
func (u *ChatContext) SetDefaultMessage(key string)
SetDefaultMessage 设置默认消息
type ChatGptConf ¶
type ChatGptConf struct { Token string `json:"token"` GroupChatPrefix []string `json:"group_chat_prefix"` GroupNameWhiteList []string `json:"group_name_white_list"` ConversationMaxTokens int `json:"conversation_max_tokens"` CharacterDesc string `json:"character_desc"` ConversationTimeout int `json:"conversation_timeout"` // contains filtered or unexported fields }
func (*ChatGptConf) AddGroupNameWhiteList ¶
func (i *ChatGptConf) AddGroupNameWhiteList(name string)
AddGroupNameWhiteList 添加群聊白名单
func (*ChatGptConf) GetDefaultPrompt ¶
func (i *ChatGptConf) GetDefaultPrompt() openai.ChatCompletionMessage
GetDefaultPrompt 获取默认的提示
func (*ChatGptConf) MatchGroupChatMentionPrefix ¶
func (i *ChatGptConf) MatchGroupChatMentionPrefix(context string) bool
MatchGroupChatMentionPrefix 判断是否是群聊@机器人的消息
func (*ChatGptConf) MatchGroupName ¶
func (i *ChatGptConf) MatchGroupName(groupName string) bool
MatchGroupName 判断是否群聊名称是否符合
func (*ChatGptConf) RemoveGroupNameWhiteList ¶
func (i *ChatGptConf) RemoveGroupNameWhiteList(name string)
RemoveGroupNameWhiteList 移除群聊白名单
func (*ChatGptConf) SetDefaultPrompt ¶
func (i *ChatGptConf) SetDefaultPrompt(value string)
SetDefaultPrompt 设置默认提示
type ConfHelper ¶
type ConfHelper struct {
// contains filtered or unexported fields
}
func NewConfHelper ¶
func NewConfHelper(file string) *ConfHelper
func NewTestConfHelper ¶
func NewTestConfHelper() *ConfHelper
func (*ConfHelper) ConversationMaxTokens ¶
func (i *ConfHelper) ConversationMaxTokens() int
ConversationMaxTokens 获取对话最大长度
func (*ConfHelper) ConversationTimeout ¶
func (i *ConfHelper) ConversationTimeout() int
ConversationTimeout 获取对话超时时间
func (*ConfHelper) GetConf ¶
func (i *ConfHelper) GetConf() *ChatGptConf
func (*ConfHelper) LoadJsonConf ¶
func (i *ConfHelper) LoadJsonConf() (conf *ChatGptConf, err error)
LoadJsonConf 从文件中加载配置
func (*ConfHelper) MatchGroupFilter ¶
func (i *ConfHelper) MatchGroupFilter(msg *openwechat.Message) (bool, string, error)
func (*ConfHelper) SaveJsonConf ¶
func (i *ConfHelper) SaveJsonConf(conf *ChatGptConf) error
SaveJsonConf 保存配置到文件
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
func (MessageHandler) GetSenderName ¶
func (h MessageHandler) GetSenderName(msg *openwechat.Message) string
GetSenderName 获取发送者名称
Click to show internal directories.
Click to hide internal directories.