diff --git a/cmd/acb/main.go b/cmd/acb/main.go index ef18c8b..bfe0272 100644 --- a/cmd/acb/main.go +++ b/cmd/acb/main.go @@ -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) diff --git a/cmd/acb/summarize.go b/cmd/acb/summarize.go index 4184c3b..e6cadfd 100644 --- a/cmd/acb/summarize.go +++ b/cmd/acb/summarize.go @@ -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 {