Skip to content

Commit

Permalink
Removed unused items from the configuration file and added the abilit…
Browse files Browse the repository at this point in the history
…y to validate subcommands
  • Loading branch information
kechigon committed Jul 16, 2024
1 parent b8f1436 commit 8f3af78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
17 changes: 12 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"log"
"os"
"strings"

"github.com/3-shake/alert-menta/internal/ai"
"github.com/3-shake/alert-menta/internal/github"
Expand All @@ -17,10 +18,7 @@ func main() {
owner = flag.String("owner", "", "Repository owner")
issueNumber = flag.Int("issue", 0, "Issue number")
intent = flag.String("intent", "", "Question or intent for the 'ask' command")
command = flag.String("command", "", `Command to be executed by AI
describe: Generate a detailed description of the Issue.
suggest: Provide suggestions for improvement based on the contents of the Issue.
ask: Answer free-text questions.`)
command = flag.String("command", "", "Commands to be executed by AI.Commands defined in the configuration file are available.")
configFile = flag.String("config", "./internal/config/config.yaml", "Configuration file")
gh_token = flag.String("github-token", "", "GitHub token")
oai_key = flag.String("api-key", "", "OpenAI api key")
Expand All @@ -38,12 +36,21 @@ func main() {
log.Ldate|log.Ltime|log.Llongfile|log.Lmsgprefix,
)

// Get configuration
// Load configuration
cfg, err := utils.NewConfig(*configFile)
if err != nil {
logger.Fatalf("Error creating comment: %s", err)
}

// Validate command
if _, ok := cfg.Ai.Commands[*command]; !ok {
allowedCommands := make([]string, 0, len(cfg.Ai.Commands))
for cmd := range cfg.Ai.Commands {
allowedCommands = append(allowedCommands, cmd)
}
logger.Fatalf("Invalid command: %s. Allowed commands are %s.", *command, strings.Join(allowedCommands, ", "))
}

// Create a GitHub Issues instance. From now on, you can control GitHub from this instance.
issue := github.NewIssue(*owner, *repo, *issueNumber, *gh_token)
if issue == nil {
Expand Down
11 changes: 3 additions & 8 deletions internal/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
system:
debug:
mode: True
log_level: debug

github:
owner: "pacificbelt30"
repo: "alert-menta"

ai:
provider: "openai" # "openai" or "vertexai"
openai:
Expand All @@ -19,11 +14,11 @@ ai:

commands:
- describe:
description: "Describe the GitHub Issues"
description: "Generate a detailed description of the Issue."
system_prompt: "The following is the GitHub Issue and comments on it. Please Generate a detailed description.\n"
- suggest:
description: "Provide suggestions for improvement based on the contents of the Issue"
description: "Provide suggestions for improvement based on the contents of the Issue."
system_prompt: "The following is the GitHub Issue and comments on it. Please identify the issues that need to be resolved based on the contents of the Issue and provide three suggestions for improvement.\n"
- ask:
description: "Ask a question about the GitHub Issue"
description: "Answer free-text questions."
system_prompt: "The following is the GitHub Issue and comments on it. Based on the content provide a detailed response to the following question:\n"

0 comments on commit 8f3af78

Please sign in to comment.