Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 3 additions & 11 deletions cmd/cli/createMsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,9 @@ func CreateCommitMsg () {
case "Claude":
commitMsg, err = claude.GenerateCommitMessage(config, changes, apiKey)
case "Ollama":
url := os.Getenv("OLLAMA_URL")
if url == "" {
url = "http://localhost:11434/api/generate"
}
model := os.Getenv("OLLAMA_MODEL")
if model == "" {
model = "llama3:latest"
}
commitMsg, err = ollama.GenerateCommitMessage(config, changes, url, model)


model := "llama3:latest"

commitMsg, err = ollama.GenerateCommitMessage(config, changes, apiKey, model)
default:
commitMsg, err = grok.GenerateCommitMessage(config, changes, apiKey)
}
Expand Down
62 changes: 45 additions & 17 deletions cmd/cli/llmSetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,30 @@ func SetupLLM() error {
var apiKey string

// Skip API key prompt for Ollama (local LLM)
if model != "Ollama" {
apiKeyPrompt := promptui.Prompt{
apiKeyPrompt := promptui.Prompt{
Label: "Enter API Key",
Mask: '*',
}


switch model {
case "Ollama":
urlPrompt := promptui.Prompt{
Label: "Enter URL",
}
apiKey, err = urlPrompt.Run()
if err != nil {
return fmt.Errorf("failed to read Url: %w", err)
}

apiKey, err = apiKeyPrompt.Run()
if err != nil {
default:
apiKey, err = apiKeyPrompt.Run()
if err != nil {
return fmt.Errorf("failed to read API Key: %w", err)
}
} else {
apiKey = "" // No API key needed for Ollama
}

}


LLMConfig := store.LLMProvider{
LLM: model,
Expand Down Expand Up @@ -68,7 +79,8 @@ func UpdateLLM() error {
}

models := []string{}
options := []string{"Set Default", "Change API Key", "Delete"}
options1 := []string{"Set Default", "Change API Key", "Delete"}
options2 := []string{"Set Default", "Change URL", "Delete"} //different option for local model

for _, p := range SavedModels.LLMProviders {
models = append(models, p.LLM)
Expand All @@ -84,19 +96,33 @@ func UpdateLLM() error {
return err
}


prompt = promptui.Select{
prompt = promptui.Select{
Label: "Select Option",
Items: options,
}
Items: options1,
}

apiKeyPrompt := promptui.Prompt {
Label: "Enter API Key",
}


if model == "Ollama" {
prompt = promptui.Select{
Label: "Select Option",
Items: options2,
}

apiKeyPrompt = promptui.Prompt {
Label: "Enter URL",
}
}


opNo,_,err := prompt.Run()
if err != nil {
return err
}

apiKeyprompt := promptui.Prompt {
Label: "Enter API Key",
}


switch opNo {
Expand All @@ -107,15 +133,17 @@ func UpdateLLM() error {
}
fmt.Printf("%s set as default", model)
case 1:
apiKey, err := apiKeyprompt.Run()
apiKey, err := apiKeyPrompt.Run()
if err != nil {
return err
}
err = store.UpdateAPIKey(model, apiKey)
if err != nil {
return err
}
fmt.Printf("%s API Key Updated", model)
event := "API Key"
if model == "Ollama"{event = "URL"}
fmt.Printf("%s %s Updated", model,event)
case 2:
err := store.DeleteModel(model)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/cli/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func DefaultLLMKey() (*LLMProvider, error) {
return nil, err
}

fmt.Println(len(data))
if len(data) > 2 {
err = json.Unmarshal(data, &cfg)
if err != nil {
Expand Down
Loading