refactor: move OpenAI variable checks into OpenAISummarizer's Summarize method and always call the summarizer's method
Co-authored-by: aider (openai/qwen3-coder:30b-a3b-q4_K_M) <aider@aider.chat>
This commit is contained in:
parent
feb06e51ff
commit
d239689ef4
1 changed files with 10 additions and 9 deletions
|
|
@ -29,6 +29,11 @@ type OpenAISummarizer struct{}
|
|||
|
||||
// Summarize sends the prompt to an OpenAI-compatible endpoint for summarization
|
||||
func (o *OpenAISummarizer) Summarize(fullPrompt string, openaiEndpoint string, openaiToken string, openaiModel string) (string, error) {
|
||||
// Check if required environment variables are set
|
||||
if openaiEndpoint == "" || openaiToken == "" {
|
||||
return "", fmt.Errorf("OpenAI endpoint or token not set")
|
||||
}
|
||||
|
||||
// Create a JSON payload for the OpenAI API
|
||||
payload := struct {
|
||||
Model string `json:"model"`
|
||||
|
|
@ -108,15 +113,11 @@ func SummarizeData(employeename string, prs map[string][]contributions.PullReque
|
|||
// Build the prompt
|
||||
fullPrompt := buildPrompt(employeename, prs, issues, tasks, prompt)
|
||||
|
||||
// Call the summarization endpoint only if OpenAI env vars are set
|
||||
if openaiEndpoint != "" && openaiToken != "" {
|
||||
result, err := summarizer.Summarize(fullPrompt, openaiEndpoint, openaiToken, openaiModel)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return result, nil
|
||||
// Always call the summarizer's Summarize method
|
||||
result, err := summarizer.Summarize(fullPrompt, openaiEndpoint, openaiToken, openaiModel)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Return just the prompt if OpenAI env vars are not set
|
||||
return fullPrompt, nil
|
||||
return result, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue