Documentation
¶
Index ¶
Constants ¶
View Source
const PreviewMaxRunes = 120
Variables ¶
This section is empty.
Functions ¶
func TruncatePreview ¶
TruncatePreview 截取前 PreviewMaxRunes 个字符作为预览文本。
Types ¶
type ExtractResult ¶
type ExtractResult struct {
Name string `json:"name"`
Description string `json:"description"`
RawContent string `json:"raw_content"`
FilePath string `json:"file_path"`
}
ExtractResult 是风格提取的返回值。
type ListOptions ¶
type ListOptions struct {
PageParams storage.PageParams
NovelID int64 // 0=仅全局,N=全局+该小说专属
Search string // 空字符串=不过滤,按 name LIKE 匹配
}
ListOptions 是 List 方法的可选过滤条件。零值表示不过滤。
type Sample ¶
type Sample struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
NovelID int64 `gorm:"column:novel_id;not null" json:"novel_id"`
IsGlobal bool `gorm:"column:is_global;not null" json:"is_global"`
Name string `gorm:"column:name;not null" json:"name"`
Content string `gorm:"column:content;not null" json:"content"`
Preview string `gorm:"column:preview;not null" json:"preview"`
Tags StringSlice `gorm:"column:tags;type:text;not null" json:"tags"`
WordCount int `gorm:"column:word_count;not null" json:"word_count"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
}
Sample 是一条风格素材的 GORM model。
type Stats ¶
type Stats struct {
TotalChars int `json:"total_chars"`
TotalWords int `json:"total_words"`
SentenceCount int `json:"sentence_count"`
ShortSentPct float64 `json:"short_sent_pct"` // <15 字
MidSentPct float64 `json:"mid_sent_pct"` // 15-30 字
LongSentPct float64 `json:"long_sent_pct"` // >30 字
AvgSentLen float64 `json:"avg_sent_len"`
SentLenStdDev float64 `json:"sent_len_std_dev"` // 句长标准差
CommaDensity float64 `json:"comma_density"` // 逗号占比
PeriodDensity float64 `json:"period_density"` // 句号占比
ExclaimDensity float64 `json:"exclaim_density"` // 感叹号占比
QuestionDensity float64 `json:"question_density"` // 问号占比
QuoteDensity float64 `json:"quote_density"` // 引号占比
ParagraphCount int `json:"paragraph_count"`
AvgParaLen float64 `json:"avg_para_len"`
}
Stats 是代码计算的确定性文本统计,不依赖 LLM。
type Store ¶
Store 管理 Sample 持久化。
func (*Store) List ¶
func (s *Store) List(ctx context.Context, opts ListOptions) (*storage.PageResult[Sample], error)
List 分页列出风格素材。 当 NovelID > 0 时,返回全局素材 + 该小说专属素材(is_global = true OR novel_id = ?); 当 NovelID == 0 时,仅返回全局素材(is_global = true)。 List 只查摘要字段,不读大 content。
type StringSlice ¶
type StringSlice []string
StringSlice 是 []string 的 DB 适配类型,存储为 JSON TEXT。
func (*StringSlice) Scan ¶
func (s *StringSlice) Scan(value any) error
Scan 实现 sql.Scanner,从 DB 读取 JSON TEXT → []string。
type StyleSkillOutput ¶
type StyleSkillOutput struct {
Name string `json:"name" jsonschema:"required,description=风格名称(中文)"`
Description string `json:"description" jsonschema:"required,description=一句话描述适合什么写作场景,什么时候调用"`
Content string `` /* 251-byte string literal not displayed */
}
StyleSkillOutput 是风格提取 toolcall 的结构化输出,由 LLM 调用 output_style_skill 工具填充。
Click to show internal directories.
Click to hide internal directories.