refactor: pass OpenAI env vars from main to SummarizeData instead of calling os.Getenv inside the function
Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat>
This commit is contained in:
parent
0520777c71
commit
2ae52d1530
2 changed files with 6 additions and 13 deletions
|
|
@ -55,15 +55,18 @@ func main() {
|
|||
// vikunjaTasks = DoVikunja(*start, *end)
|
||||
// }
|
||||
|
||||
// Check if OpenAI environment variables are set before calling Summarize
|
||||
// Get OpenAI environment variables
|
||||
openaiEndpoint := os.Getenv("OPENAI_ENDPOINT")
|
||||
openaiToken := os.Getenv("OPENAI_TOKEN")
|
||||
openaiModel := os.Getenv("OPENAI_MODEL")
|
||||
|
||||
// Check if OpenAI environment variables are set before calling Summarize
|
||||
if openaiEndpoint == "" || openaiToken == "" {
|
||||
fmt.Println("Error: OPENAI_ENDPOINT and OPENAI_TOKEN must be set in environment variables to summarize")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
summ, err := SummarizeData(*employeename, prs, issues, vikunjaTasks, *prompt)
|
||||
summ, err := SummarizeData(*employeename, prs, issues, vikunjaTasks, *prompt, openaiEndpoint, openaiToken, openaiModel)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("error getting PRs: %w", err))
|
||||
os.Exit(1)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"o5r.ca/autocrossbow/contributions"
|
||||
|
|
@ -20,16 +19,7 @@ I'd like you to summarize the employee's accomplishments for the quarter
|
|||
I'd like the summary for the accomplishments to be in prose form, in a few paragraphs separated based on areas of work. Keep answers to 500 words for the summary.`
|
||||
|
||||
// SummarizeData takes GitHub PRs and Jira issues data and sends it to an OpenAI-compatible endpoint for summarization.
|
||||
func SummarizeData(employeename string, prs map[string][]contributions.PullRequest, issues []issues.Issue, tasks []vikunja.Task, prompt string) (string, error) {
|
||||
// Get OpenAI endpoint and token from environment variables
|
||||
openaiEndpoint := os.Getenv("OPENAI_ENDPOINT")
|
||||
openaiToken := os.Getenv("OPENAI_TOKEN")
|
||||
openaiModel := os.Getenv("OPENAI_MODEL")
|
||||
|
||||
if openaiEndpoint == "" || openaiToken == "" {
|
||||
return "", fmt.Errorf("OPENAI_ENDPOINT and OPENAI_TOKEN must be set in environment variables")
|
||||
}
|
||||
|
||||
func SummarizeData(employeename string, prs map[string][]contributions.PullRequest, issues []issues.Issue, tasks []vikunja.Task, prompt string, openaiEndpoint string, openaiToken string, openaiModel string) (string, error) {
|
||||
// Build a prompt string
|
||||
fullPrompt := prompt + fmt.Sprintf("\n\nHere's the PRs and Tickets for the employee %s:\n\n", employeename)
|
||||
for repo, prList := range prs {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue