Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ai/openai
Browse files Browse the repository at this point in the history
  • Loading branch information
pacificbelt30 committed Jun 17, 2024
2 parents a3c9975 + 72633e7 commit 106b1a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 5 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ func main() {
owner = flag.String("owner", "", "Repository owner")
issueNumber = flag.Int("issue", 0, "Issue number")
command = flag.String("command", "", "Command to be executed by AI")
token = flag.String("token", "", "GitHub token")
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")
)
flag.Parse()

if *repo == "" || *owner == "" || *issueNumber == 0 || *token == "" || *command == "" {
if *repo == "" || *owner == "" || *issueNumber == 0 || *gh_token == "" || *oai_key == "" || *command == "" {
flag.PrintDefaults()
os.Exit(1)
}
Expand All @@ -41,7 +42,7 @@ func main() {
}

// Create GitHub Issues instance
issue := github.NewIssue(*owner, *repo, *issueNumber, *token)
issue := github.NewIssue(*owner, *repo, *issueNumber, *gh_token)

// Get Issue's info
title, _ := issue.GetTitle()
Expand All @@ -65,7 +66,7 @@ func main() {

// Get response from OpenAI
logger.Println("Prompt:", system_prompt, user_prompt)
ai := ai.NewOpenAIClient("", cfg.Ai.Model)
ai := ai.NewOpenAIClient(*oai_key, cfg.Ai.Model)
comment, _ := ai.GetResponse(system_prompt + user_prompt)
logger.Println("Response:", comment)

Expand Down
3 changes: 0 additions & 3 deletions internal/ai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ai
import (
"context"
"fmt"
"os"

"github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
Expand Down Expand Up @@ -45,13 +44,11 @@ func (ai *OpenAI) GetResponse(prompt string) (string, error) {

func NewOpenAIClient(apiKey string, model string) *OpenAI {
// Set the OpenAI API key (read from the environment variable)
apiKey = os.Getenv("OPENAI_API_KEY")
if apiKey == "" {
fmt.Println("Error: OPENAI_API_KEY environment variable not set.")
return nil
}
// Specifying the model to use
model = "gpt-3.5-turbo"
return &OpenAI{
apiKey: apiKey,
model: model,
Expand Down

0 comments on commit 106b1a7

Please sign in to comment.