Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP pb analyze stream #72

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handler error, add steps to another
AdheipSingh committed Nov 27, 2024
commit ebba245530ba1148c2089a585c7a61762dd19f83
26 changes: 22 additions & 4 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
@@ -129,6 +129,12 @@
return fmt.Errorf(red+"Error fetching pod events: %w\n"+reset, err)
}

// debug for empty results
if result == nil {
fmt.Println(yellow + "No results found in DuckDB." + reset)
return nil
}

s.Suffix = " Analyzing events with LLM..."
s.Start()

@@ -139,6 +145,10 @@
if llmProvider == "openai" {
// Use OpenAI's AnalyzeEventsWithGPT function
gptResponse, err = openai.AnalyzeEventsWithGPT(pod, namespace, result)

fmt.Println(
gptResponse,
)
} else if llmProvider == "anthropic" {
// Use Anthropic's AnalyzeEventsWithAnthropic function
gptResponse, err = anthropic.AnalyzeEventsWithAnthropic(pod, namespace, result)
@@ -299,7 +309,7 @@
var analysis AnalysisResponse
err := json.Unmarshal([]byte(response), &analysis)
if err != nil {
log.Fatalf("Failed to parse LLM response: %v", err)
log.Println("Failed to parse LLM response: %v", err)

Check failure on line 312 in cmd/analyze.go

GitHub Actions / Build and Test the Go code

log.Println call has possible Printf formatting directive %v
}

// Display the summary by default
@@ -308,7 +318,7 @@
// Prompt the user to choose between "Root Cause Analysis" and "Mitigation Steps"
initialPrompt := promptui.Select{
Label: "Select Analysis to View",
Items: []string{"Root Cause Analysis", "Mitigation Steps"},
Items: []string{"Root Cause Analysis", "Mitigation Steps", "Analyze another pod in namespace (yes/no)"},
Size: 3,
}

@@ -325,7 +335,7 @@
// Now prompt the user to choose between "Mitigation" or "Pods"
secondPrompt := promptui.Select{
Label: "What would you like to do next?",
Items: []string{"Mitigation"},
Items: []string{"Mitigation", "Analyze another pod in namespace (yes/no)"},
Size: 3,
}

@@ -351,7 +361,15 @@
if strings.ToLower(choice) != "yes" {
return false // Exit the loop if "no"
}

case "Analyze another pod in namespace (yes/no)":
prompt := promptui.Prompt{
Label: "Analyze another namespace/pod (yes/no)",
Default: "no",
}
choice, _ := prompt.Run()
if strings.ToLower(choice) != "yes" {
return false // Exit the loop if "no"
}
}

case "Mitigation Steps":