Documentation ¶
Index ¶
- Variables
- func NewClient() func(NewClientParams) (Client, error)
- type AnySummarizationInputs
- type ChatHistorySummarizationOutputs
- type ChatHistorySummarizationOutputsDiscussion
- type ChatHistorySummarizationPromptInputs
- type Client
- type NewClientParams
- type OpenAIClient
- func (c *OpenAIClient) SplitContentBasedByTokenLimitations(textContent string, limits int) []string
- func (c *OpenAIClient) SummarizeAny(ctx context.Context, content string) (*openai.ChatCompletionResponse, error)
- func (c *OpenAIClient) SummarizeChatHistories(ctx context.Context, llmFriendlyChatHistories string) (*openai.ChatCompletionResponse, error)
- func (c *OpenAIClient) SummarizeOneChatHistory(ctx context.Context, llmFriendlyChatHistory string) (*openai.ChatCompletionResponse, error)
- func (c *OpenAIClient) SummarizeWithQuestionsAsSimplifiedChinese(ctx context.Context, title, by, content string) (*openai.ChatCompletionResponse, error)
- func (c *OpenAIClient) TruncateContentBasedOnTokens(textContent string, limits int) string
Constants ¶
This section is empty.
Variables ¶
View Source
var AnySummarizationPrompt = lo.Must(template.New("anything summarization prompt").Parse("" +
`内容:{{ .Content }}
你是我的总结助手。我将为你提供一段话,我需要你在不丢失原文主旨和情感、不做更多的解释和说明的情况下帮我用不超过100字总结一下这段话说了什么。`))
View Source
var ChatHistorySummarizationPrompt = lo.Must(template.New("chat histories summarization prompt").Parse("" +
`Chat histories:"""
{{ .ChatHistory }}
"""
You are my chat histories summary and review assistant. Above are chat histories, each message starts with msgId, please summarize these chats as 1 to 5 topics, each topic should contain the following fields: sinceId (msgId at the beginning of the topic)、keyIds (key msgId in the discussion, max 5 msgIds) and conclusion (ignore this field if no clear conclusion). Please output as the following JSON format without additional explanation using {{ .Language }}:"""
[{"topicName":"..","sinceId":123456789,"participantsNamesWithoutUsername":[".."],"discussion":[{"point":"..","keyIds":[123456789]}],"conclusion":".."}]"""`))
Functions ¶
func NewClient ¶
func NewClient() func(NewClientParams) (Client, error)
Types ¶
type AnySummarizationInputs ¶
type AnySummarizationInputs struct {
Content string
}
type ChatHistorySummarizationOutputs ¶
type ChatHistorySummarizationOutputs struct { TopicName string `json:"topicName"` SinceID int64 `json:"sinceId"` ParticipantsNamesWithoutUsername []string `json:"participantsNamesWithoutUsername"` Discussion []*ChatHistorySummarizationOutputsDiscussion `json:"discussion"` Conclusion string `json:"conclusion"` }
type ChatHistorySummarizationPromptInputs ¶
func NewChatHistorySummarizationPromptInputs ¶
func NewChatHistorySummarizationPromptInputs(chatHistory string, language string) *ChatHistorySummarizationPromptInputs
type Client ¶
type Client interface { SplitContentBasedByTokenLimitations(textContent string, limits int) []string SummarizeAny(ctx context.Context, content string) (*openai.ChatCompletionResponse, error) SummarizeChatHistories(ctx context.Context, llmFriendlyChatHistories string) (*openai.ChatCompletionResponse, error) SummarizeOneChatHistory(ctx context.Context, llmFriendlyChatHistory string) (*openai.ChatCompletionResponse, error) SummarizeWithQuestionsAsSimplifiedChinese(ctx context.Context, title string, by string, content string) (*openai.ChatCompletionResponse, error) TruncateContentBasedOnTokens(textContent string, limits int) string }
type NewClientParams ¶
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
func (*OpenAIClient) SplitContentBasedByTokenLimitations ¶
func (c *OpenAIClient) SplitContentBasedByTokenLimitations(textContent string, limits int) []string
SplitContentBasedByTokenLimitations 基于 token 计算的方式分割文本。
func (*OpenAIClient) SummarizeAny ¶
func (c *OpenAIClient) SummarizeAny(ctx context.Context, content string) (*openai.ChatCompletionResponse, error)
SummarizeAny 通过 OpenAI 的 Chat API 来为任意内容生成摘要。
func (*OpenAIClient) SummarizeChatHistories ¶
func (c *OpenAIClient) SummarizeChatHistories(ctx context.Context, llmFriendlyChatHistories string) (*openai.ChatCompletionResponse, error)
func (*OpenAIClient) SummarizeOneChatHistory ¶
func (c *OpenAIClient) SummarizeOneChatHistory(ctx context.Context, llmFriendlyChatHistory string) (*openai.ChatCompletionResponse, error)
func (*OpenAIClient) SummarizeWithQuestionsAsSimplifiedChinese ¶
func (c *OpenAIClient) SummarizeWithQuestionsAsSimplifiedChinese(ctx context.Context, title, by, content string) (*openai.ChatCompletionResponse, error)
SummarizeWithQuestionsAsSimplifiedChinese 通过 OpenAI 的 Chat API 来为文章生成摘要和联想问题。
func (*OpenAIClient) TruncateContentBasedOnTokens ¶
func (c *OpenAIClient) TruncateContentBasedOnTokens(textContent string, limits int) string
truncateContentBasedOnTokens 基于 token 计算的方式截断文本。
Click to show internal directories.
Click to hide internal directories.