all repos — llm_aggregator @ master

A CLI tool to aggregate RSS feeds and summarise them with LLMs

internal/aggregator/article.go (view raw)

 1package aggregator
 2
 3import "time"
 4
 5// Article represents an item extracted from an RSS feed.
 6type Article struct {
 7	Title      string    `json:"title"`
 8	Link       string    `json:"link"`
 9	Content    string    `json:"content"`
10	Published  time.Time `json:"published"`
11	Author     string    `json:"author,omitempty"`
12	SourceFeed string    `json:"source_feed,omitempty"`
13	Summary    string    `json:"summary,omitempty"`
14}
15
16// ToMap serialises the article to a map for LLM input or JSON output.
17// Content is truncated to 500 chars to avoid oversized prompts.
18func (a *Article) ToMap() map[string]any {
19	content := a.Content
20	if len(content) > 500 {
21		content = content[:500] + "... [truncated]"
22	}
23
24	result := map[string]any{
25		"title":       a.Title,
26		"link":        a.Link,
27		"content":     content,
28		"author":      a.Author,
29		"source_feed": a.SourceFeed,
30		"summary":     a.Summary,
31	}
32
33	if !a.Published.IsZero() {
34		result["published"] = a.Published.Format(time.RFC3339)
35	}
36
37	return result
38}
39