chathistories

package
v0.15.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RecapOutputTemplate = lo.Must(template.
	New("recap output markdown template").
	Funcs(template.FuncMap{
		"join":   strings.Join,
		"sub":    func(a, b int) int { return a - b },
		"add":    func(a, b int) int { return a + b },
		"escape": tgbot.EscapeHTMLSymbols,
	}).
	Parse(`{{ $chatID := .ChatID }}{{ if .Recap.SinceID }}## <a href="https://t.me/c/{{ $chatID }}/{{ .Recap.SinceID }}">{{ escape .Recap.TopicName }}</a>{{ else }}## {{ escape .Recap.TopicName }}{{ end }}
参与人:{{ join .Recap.ParticipantsNamesWithoutUsername "," }}
讨论:{{ range $di, $d := .Recap.Discussion }}
 - {{ escape $d.Point }}{{ if len $d.KeyIDs }} {{ range $cIndex, $c := $d.KeyIDs }}<a href="https://t.me/c/{{ $chatID }}/{{ $c }}">[{{ add $cIndex 1 }}]</a>{{ if not (eq $cIndex (sub (len $d.KeyIDs) 1)) }} {{ end }}{{ end }}{{ end }}{{ end }}{{ if .Recap.Conclusion }}
结论:{{ escape .Recap.Conclusion }}{{ end }}`))

Functions

func NewModel

func NewModel() func(NewModelParams) (*Model, error)

Types

type FromPlatform

type FromPlatform int
const (
	FromPlatformTelegram FromPlatform = iota
)

type Model

type Model struct {
	// contains filtered or unexported fields
}

func (*Model) DisableRecapForwardedFromPrivateMessages added in v0.14.0

func (m *Model) DisableRecapForwardedFromPrivateMessages(userID int64) error

func (*Model) EnabledRecapForwardedFromPrivateMessages added in v0.14.0

func (m *Model) EnabledRecapForwardedFromPrivateMessages(userID int64) error

func (*Model) ExtractTextFromMessage

func (m *Model) ExtractTextFromMessage(message *tgbotapi.Message) string

func (*Model) FindChatHistoriesByTimeBefore

func (m *Model) FindChatHistoriesByTimeBefore(chatID int64, before time.Duration) ([]*ent.ChatHistories, error)

func (*Model) FindLastOneHourChatHistories

func (m *Model) FindLastOneHourChatHistories(chatID int64) ([]*ent.ChatHistories, error)

func (*Model) FindLastSixHourChatHistories

func (m *Model) FindLastSixHourChatHistories(chatID int64) ([]*ent.ChatHistories, error)

func (*Model) FindPrivateForwardedChatHistories added in v0.14.0

func (m *Model) FindPrivateForwardedChatHistories(userID int64) ([]telegramPrivateForwardedReplayChatHistory, error)

func (*Model) HasOngoingRecapForwardedFromPrivateMessages added in v0.14.0

func (m *Model) HasOngoingRecapForwardedFromPrivateMessages(userID int64) (bool, error)

func (*Model) SaveOneTelegramChatHistory

func (m *Model) SaveOneTelegramChatHistory(message *tgbotapi.Message) error

func (*Model) SaveOneTelegramPrivateForwardedReplayChatHistory added in v0.14.0

func (m *Model) SaveOneTelegramPrivateForwardedReplayChatHistory(message *tgbotapi.Message) error

func (*Model) SummarizeChatHistories

func (m *Model) SummarizeChatHistories(chatID int64, histories []*ent.ChatHistories) ([]string, error)

func (*Model) SummarizePrivateForwardedChatHistories added in v0.14.0

func (m *Model) SummarizePrivateForwardedChatHistories(userID int64, histories []telegramPrivateForwardedReplayChatHistory) ([]string, error)

func (*Model) UpdateOneTelegramChatHistory

func (m *Model) UpdateOneTelegramChatHistory(message *tgbotapi.Message) error

type NewModelParams

type NewModelParams struct {
	fx.In

	Lifecycle fx.Lifecycle

	Logger *logger.Logger
	Ent    *datastore.Ent
	OpenAI openai.Client
	Redis  *datastore.Redis
}

type RecapOutputTemplateInputs

type RecapOutputTemplateInputs struct {
	ChatID string
	Recap  *openai.ChatHistorySummarizationOutputs
}

type RecapType added in v0.14.0

type RecapType int
const (
	RecapTypeForGroup RecapType = iota
	RecapTypeForPrivateForwarded
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL