dialog

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package dialog 提供对话偏好提取功能 从用户对话中自动识别偏好、约束、风格等信息

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtractedPreference

type ExtractedPreference struct {
	// Category 分类
	Category PreferenceCategory `json:"category"`

	// Content 内容
	Content string `json:"content"`

	// Keywords 匹配的关键词
	Keywords []string `json:"keywords"`

	// Confidence 置信度
	Confidence float64 `json:"confidence"`

	// Timestamp 提取时间
	Timestamp time.Time `json:"timestamp"`
}

ExtractedPreference 提取的偏好

type Extractor

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

Extractor 对话偏好提取器

func NewExtractor

func NewExtractor(keywords KeywordMatrix, config *ExtractorConfig) *Extractor

NewExtractor 创建提取器

func (*Extractor) AddKeywords

func (e *Extractor) AddKeywords(category PreferenceCategory, keywords []string)

AddKeywords 添加关键词

func (*Extractor) Extract

func (e *Extractor) Extract(message string) []*ExtractedPreference

Extract 从消息中提取偏好

func (*Extractor) HasPreferenceKeyword

func (e *Extractor) HasPreferenceKeyword(message string) bool

HasPreferenceKeyword 检查消息是否包含偏好关键词

func (*Extractor) SetKeywords

func (e *Extractor) SetKeywords(keywords KeywordMatrix)

SetKeywords 设置关键词矩阵

type ExtractorConfig

type ExtractorConfig struct {
	// MinConfidence 最低置信度
	MinConfidence float64

	// MaxExtractLength 最大提取长度
	MaxExtractLength int
}

ExtractorConfig 提取器配置

func DefaultExtractorConfig

func DefaultExtractorConfig() *ExtractorConfig

DefaultExtractorConfig 默认配置

type KeywordMatrix

type KeywordMatrix map[PreferenceCategory][]string

KeywordMatrix 关键词矩阵

func ContentPlatformKeywords

func ContentPlatformKeywords() KeywordMatrix

ContentPlatformKeywords 内容平台关键词

func DefaultChineseKeywords

func DefaultChineseKeywords() KeywordMatrix

DefaultChineseKeywords 返回默认中文关键词矩阵

func DefaultEnglishKeywords

func DefaultEnglishKeywords() KeywordMatrix

DefaultEnglishKeywords 返回默认英文关键词矩阵

func MarketingContentKeywords

func MarketingContentKeywords() KeywordMatrix

MarketingContentKeywords 营销内容关键词

func TechnicalWritingKeywords

func TechnicalWritingKeywords() KeywordMatrix

TechnicalWritingKeywords 技术写作关键词

func WritingStyleKeywords

func WritingStyleKeywords() KeywordMatrix

WritingStyleKeywords 写作风格关键词(扩展)

type PreferenceCategory

type PreferenceCategory string

PreferenceCategory 偏好分类

const (
	// CategoryPreference 一般偏好
	CategoryPreference PreferenceCategory = "preference"
	// CategoryConstraint 约束条件
	CategoryConstraint PreferenceCategory = "constraint"
	// CategoryStyle 风格偏好
	CategoryStyle PreferenceCategory = "style"
	// CategoryAudience 受众偏好
	CategoryAudience PreferenceCategory = "audience"
	// CategoryLength 长度偏好
	CategoryLength PreferenceCategory = "length"
	// CategoryFormat 格式偏好
	CategoryFormat PreferenceCategory = "format"
)

Jump to

Keyboard shortcuts

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