Documentation
¶
Index ¶
- Variables
- type ChatContext
- func (c *ChatContext) GetMaxSeqTimes() int
- func (c *ChatContext) LoadConversation(path string) error
- func (c *ChatContext) PollConversation()
- func (c *ChatContext) ResetConversation()
- func (c *ChatContext) SaveConversation(path string) error
- func (c *ChatContext) SetAiRole(role string)
- func (c *ChatContext) SetBackground(background string)
- func (c *ChatContext) SetHumanRole(role string)
- func (c *ChatContext) SetMaxSeqTimes(times int)
- func (c *ChatContext) SetPreset(preset string)
- type ChatContextOption
- type ChatGPT
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultAiRole = "AI" DefaultHumanRole = "Human" DefaultCharacter = []string{"helpful", "creative", "clever", "friendly", "lovely", "talkative"} DefaultBackground = "The following is a conversation with AI assistant. The assistant is %s" DefaultPreset = "\n%s: 你好,让我们开始愉快的谈话!\n%s: 我是 AI assistant ,请问你有什么问题?" )
View Source
var OverMaxQuestionLength = errors.New("maximum question length exceeded")
OverMaxQuestionLength 超过最大问题长度
View Source
var OverMaxSequenceTimes = errors.New("maximum conversation times exceeded")
OverMaxSequenceTimes 超过最大对话时间
View Source
var OverMaxTextLength = errors.New("maximum text length exceeded")
OverMaxTextLength 超过最大文本长度
Functions ¶
This section is empty.
Types ¶
type ChatContext ¶
type ChatContext struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(options ...ChatContextOption) *ChatContext
func (*ChatContext) GetMaxSeqTimes ¶
func (c *ChatContext) GetMaxSeqTimes() int
func (*ChatContext) LoadConversation ¶
func (c *ChatContext) LoadConversation(path string) error
LoadConversation 加载对话
func (*ChatContext) PollConversation ¶
func (c *ChatContext) PollConversation()
PollConversation 移除最旧的一则对话
func (*ChatContext) ResetConversation ¶
func (c *ChatContext) ResetConversation()
ResetConversation 重置对话
func (*ChatContext) SaveConversation ¶
func (c *ChatContext) SaveConversation(path string) error
SaveConversation 保存对话
func (*ChatContext) SetAiRole ¶
func (c *ChatContext) SetAiRole(role string)
func (*ChatContext) SetBackground ¶
func (c *ChatContext) SetBackground(background string)
func (*ChatContext) SetHumanRole ¶
func (c *ChatContext) SetHumanRole(role string)
func (*ChatContext) SetMaxSeqTimes ¶
func (c *ChatContext) SetMaxSeqTimes(times int)
func (*ChatContext) SetPreset ¶
func (c *ChatContext) SetPreset(preset string)
type ChatContextOption ¶
type ChatContextOption func(*ChatContext)
func WithMaintainSeqTimes ¶
func WithMaintainSeqTimes(maintain bool) ChatContextOption
func WithMaxSeqTimes ¶
func WithMaxSeqTimes(times int) ChatContextOption
func WithOldConversation ¶
func WithOldConversation(path string) ChatContextOption
WithOldConversation 从文件中加载对话
type ChatGPT ¶
type ChatGPT struct {
ChatContext *ChatContext
// contains filtered or unexported fields
}
func (*ChatGPT) ChatWithContext ¶
func (*ChatGPT) GetDoneChan ¶
func (c *ChatGPT) GetDoneChan() chan struct{}
func (*ChatGPT) SetMaxQuestionLen ¶
Click to show internal directories.
Click to hide internal directories.