Skip to content

Commit 367a5a7

Browse files
committed
centralize initiation
1 parent 81e204a commit 367a5a7

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ func bootstrapConfig() {
138138
if viper.IsSet("openai_model") {
139139
openaiModel = viper.Get("openai_model").(string)
140140
}
141-
141+
if viper.IsSet("summary_prompt") {
142+
summaryPrompt = viper.Get("summary_prompt").(string)
143+
}
142144
if viper.IsSet("summary_feeds") {
143145
summaryFeeds := viper.Get("summary_feeds")
144146

feeds_writer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var show_images bool
2828
var sunrise_sunset bool
2929
var myFeeds []RSS
3030
var db *sql.DB
31+
var summaryPrompt string
3132

3233
type RSS struct {
3334
url string

summarize.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ func summarize(text string) string {
3232
return ""
3333
}
3434

35-
summaryPrompt := viper.GetString("summary_prompt")
36-
if summaryPrompt == "" {
37-
summaryPrompt = "Summarize the following text:"
35+
prompt := summaryPrompt
36+
if prompt == "" {
37+
prompt = "Summarize the following text:"
3838
}
3939

4040
clientConfig := openai.DefaultConfig(openaiApiKey)
@@ -53,7 +53,7 @@ func summarize(text string) string {
5353
Messages: []openai.ChatCompletionMessage{
5454
{
5555
Role: openai.ChatMessageRoleAssistant,
56-
Content: summaryPrompt,
56+
Content: prompt,
5757
},
5858
{
5959
Role: openai.ChatMessageRoleUser,

0 commit comments

Comments
 (0)