diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml deleted file mode 100644 index 18e606e..0000000 --- a/.github/workflows/greetings.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Greetings - -on: [pull_request_target, issues] - -jobs: - greeting: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: "👋 Welcome to LazyAI! Thank you for taking the time to open your first issue. We appreciate your contribution and are excited to see how we can improve LazyAI together. Please make sure you've included all relevant details so we can better understand and address your concern. If you haven't already, check out our [CONTRIBUTING.md](https://github.com/your-username/LazyAI/blob/main/CONTRIBUTING.md) for guidelines on how to contribute effectively. We'll review your issue soon and get back to you. Happy coding! 🚀" - pr-message: "🎉 Congratulations on your first pull request to LazyAI! We're thrilled to see your contribution. Your efforts to improve LazyAI are greatly appreciated. Our team will review your changes soon. In the meantime, please ensure your PR adheres to our contribution guidelines outlined in [CONTRIBUTING.md](https://github.com/your-username/LazyAI/blob/main/CONTRIBUTING.md). If any changes are needed, we'll let you know. Thank you for helping make LazyAI better for everyone! 💪" diff --git a/main.go b/main.go index 02d114c..e804b02 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ var ( FileLocation string HistoryLocation string PromptText = panes.PromptText + SelectedModel = panes.Selected ) func init() { @@ -29,7 +30,7 @@ func init() { err = os.MkdirAll(filepath.Dir(HistoryLocation), os.ModePerm) checkNilErr(err) - logFile, _ := os.OpenFile("lazyai.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) + logFile, _ := os.OpenFile("lazyai.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o666) log.SetOutput(logFile) } @@ -50,8 +51,17 @@ func setupUI(detachedMode *bool, app *tview.Application) { } } +func throwInvalidModelErr() { + fmt.Println("Invalid model used, available models:") + for _, model := range panes.AvailableModels { + fmt.Println(model.SelectedModel) + } + os.Exit(0) +} + func main() { detachedMode := flag.Bool("d", false, "Run in detached mode") + defaultModel := flag.String("m", "gemini-2.0-flash", "Set the default model to use") defaultPrompt := flag.String("p", "", "Set the default prompt") helpCommand := flag.Bool("help", false, "Show help commands") flag.Parse() @@ -70,6 +80,21 @@ func main() { PromptText.PromptString = *defaultPrompt } + // check if we support specified model + validModel := false + for _, v := range panes.AvailableModels { + if v.SelectedModel == *defaultModel { + validModel = true + break + } + } + + if !validModel { + throwInvalidModelErr() + } + + panes.Selected.SelectedModel = *defaultModel + app := tview.NewApplication().EnableMouse(true) if !api.CheckCredentials(FileLocation, nil) { @@ -80,7 +105,7 @@ func main() { return } - err := os.WriteFile(FileLocation, []byte(apiInput), 0644) + err := os.WriteFile(FileLocation, []byte(apiInput), 0o644) checkNilErr(err) log.Println("Starting clipboard monitoring after credential input.") diff --git a/panes/modelsPane.go b/panes/modelsPane.go index 1d25d8c..db7c5f3 100644 --- a/panes/modelsPane.go +++ b/panes/modelsPane.go @@ -26,7 +26,7 @@ func init() { SelectModel(availableModels["Gemini 2.5 Flash"].SelectedModel) // Add models to the list - for key, model := range availableModels { + for key, model := range AvailableModels { currentModel := model ModelList.AddItem(key, "", 0, func() { SelectModel(currentModel.SelectedModel) @@ -39,7 +39,7 @@ func init() { case tcell.KeyEnter: currentItem := ModelList.GetCurrentItem() mainText, _ := ModelList.GetItemText(currentItem) - SelectModel(availableModels[mainText].SelectedModel) + SelectModel(AvailableModels[mainText].SelectedModel) } return event }) diff --git a/panes/outputPane.go b/panes/outputPane.go index 34d6f9e..45b7870 100644 --- a/panes/outputPane.go +++ b/panes/outputPane.go @@ -18,10 +18,11 @@ var ( ) func init() { - var commands string = "\n## Commands:\n\n" + + commands := "\n## Commands:\n\n" + "- run the application: `lazyAi`\n\n" + "- run the application in detached mode: `lazyAi -d`\n" + - "- run the application with a default prompt: `lazyAi -p \"your prompt here\"`\n" + "- run the application with a default prompt: `lazyAi -p \"your prompt here\"`\n" + + "- run the application with a default model: `lazyAi -m \"gemini-2.0-flash\"`\n" helpcmd := true HelpCommands = MarkdownToTview(commands, &helpcmd)