Skip to content

Commit

Permalink
Merge pull request #22 from piqoni/openai_integration
Browse files Browse the repository at this point in the history
Summarize Feature via GPT-3
  • Loading branch information
piqoni authored Feb 17, 2023
2 parents ecddb24 + 4cb95d8 commit 6152bfb
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 13 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

Matcha is a daily digest generator for your RSS feeds and interested topics/keywords. By using any markdown file viewer (such as [Obsidian](https://obsidian.md/)) or directly from terminal (-t option), you can read your RSS articles whenever you want at your pace, thus avoiding FOMO throughout the day.
### In Obsidian
<img width="900" alt="image" src="https://user-images.githubusercontent.com/3144671/206862015-9a325a14-cd8b-4ac3-97bc-55c81008c0df.png">
<img width="900" alt="image" src="https://user-images.githubusercontent.com/3144671/219786799-55db70c1-5860-4d4b-9df4-b81a89f8161d.png">

### On the terminal

<img width="596" alt="image" src="https://user-images.githubusercontent.com/3144671/208323296-af2d6a51-7d33-42a9-a827-0e96a4a383fd.png">

## Features
- RSS daily **digest**, it will show only articles not previously seen
- Summarized articles from OpenAI for selected feeds
- Weather for the next 12 Hours (from [YR](https://www.yr.no/))
- Quick bookmarking of articles to Instapaper
- Interested Topics/Keywords to follow (through [Google News](https://news.google.com/))
Expand Down Expand Up @@ -56,6 +57,17 @@ terminal_mode: false
opml_file_path:
markdown_file_prefix:
markdown_file_suffix:
openai_api_key:
summary_feeds:
```
### GPT-3 Summary of Articles
To use the summary feature, you need to an OpanAI account ([sign up here](https://openai.com/api/)) then get your API key [here](https://openai.com/api/).
Then update the configuration with the feeds you want to be summarized under "summary_feeds" setting, example:
```
openai_api_key: xxxxxxxxxxxxxxxxx
summary_feeds:
- http://hnrss.org/best
```
### Command line Options
Run matcha with --help option to see current cli options:
Expand Down
20 changes: 16 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ weather_longitude: 122.41
terminal_mode: false
opml_file_path:
markdown_file_prefix:
markdown_file_suffix: `
markdown_file_suffix:
openai_api_key:
summary_feeds: `

func parseOPML(xmlContent []byte) []RSS {
o := Opml{}
Expand Down Expand Up @@ -105,17 +107,27 @@ func bootstrapConfig() {
if viper.IsSet("markdown_file_suffix") {
mdSuffix = viper.Get("markdown_file_suffix").(string)
}
if viper.IsSet("openai_api_key") {
openaiApiKey = viper.Get("openai_api_key").(string)
}

var limit = 20
if viper.IsSet("summary_feeds") {
summaryFeeds := viper.Get("summary_feeds")

for _, summaryFeed := range summaryFeeds.([]any) {

myMap = append(myMap, RSS{url: summaryFeed.(string), limit: limit, summarize: true})
}
}

var limit int
for _, feed := range feeds.([]any) {
chopped := strings.Split(feed.(string), " ")
if len(chopped) > 1 {
limit, err = strconv.Atoi(chopped[1])
if err != nil {
check(err)
}
} else {
limit = 20
}

myMap = append(myMap, RSS{url: chopped[0], limit: limit})
Expand Down
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ require (
modernc.org/sqlite v1.20.0
)

require (
github.com/go-shiori/dom v0.0.0-20210627111528-4e4722cd0d65 // indirect
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
)

require (
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/andybalholm/cascadia v1.1.0 // indirect
github.com/andybalholm/cascadia v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-shiori/go-readability v0.0.0-20220215145315-dd6828d2f09b
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -26,6 +33,7 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/sashabaranov/go-gpt3 v1.0.1
github.com/savioxavier/termlink v1.2.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
Expand Down
Loading

0 comments on commit 6152bfb

Please sign in to comment.