yessss
This commit is contained in:
parent
c215536745
commit
ef6e0c97d2
3 changed files with 57 additions and 18 deletions
|
|
@ -7,13 +7,20 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"o5r.ca/autocrossbow/contributions"
|
||||
"o5r.ca/autocrossbow/issues"
|
||||
)
|
||||
|
||||
const defaultPrompt = `I will provide you, for a given period, with an employee name and a list of Pull Request titles and summaries split by repository, and a list of Jira Issues an employee has worked on. I may also provide, optionally, the employee's self-assessment. If I do, integrate that.
|
||||
|
||||
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(prs map[string][]PullRequest, issues []Issue) (string, error) {
|
||||
func SummarizeData(employeename string, prs map[string][]contributions.PullRequest, issues []issues.Issue) (string, error) {
|
||||
// Build a prompt string
|
||||
prompt := "Summarize the following GitHub PRs and Jira issues:\n\n"
|
||||
prompt := defaultPrompt + fmt.Sprintf("\n\nHere's the PRs and Tickets for the employee %s:\n\n", employeename)
|
||||
for repo, prList := range prs {
|
||||
prompt += fmt.Sprintf("Repository: %s\n", repo)
|
||||
for _, pr := range prList {
|
||||
|
|
@ -21,23 +28,39 @@ func SummarizeData(prs map[string][]PullRequest, issues []Issue) (string, error)
|
|||
prompt += fmt.Sprintf(" Body: %s\n", pr.Body)
|
||||
}
|
||||
}
|
||||
prompt += fmt.Sprintf("Issues:")
|
||||
for _, issue := range issues {
|
||||
prompt += fmt.Sprintf("\nJira Issue: %s\n", issue.Key)
|
||||
prompt += fmt.Sprintf("Summary: %s\n", issue.Summary)
|
||||
prompt += fmt.Sprintf("Description: %s\n", issue.Description)
|
||||
prompt += fmt.Sprintf("--------")
|
||||
}
|
||||
|
||||
// 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")
|
||||
}
|
||||
|
||||
// Create a JSON payload for the OpenAI API
|
||||
payload := map[string]string{"prompt": prompt}
|
||||
payload := struct {
|
||||
Model string `json:"model"`
|
||||
Messages []struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
} `json:"messages"`
|
||||
}{
|
||||
Model: openaiModel,
|
||||
Messages: []struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
}{{Role: "system", Content: prompt}},
|
||||
}
|
||||
|
||||
jsonPayload, err := json.Marshal(payload)
|
||||
fmt.Println(string(jsonPayload))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -62,5 +85,7 @@ func SummarizeData(prs map[string][]PullRequest, issues []Issue) (string, error)
|
|||
return "", err
|
||||
}
|
||||
|
||||
//parts := strings.Split(body, "think")
|
||||
|
||||
return string(body), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue