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
16 changes: 0 additions & 16 deletions .github/workflows/greetings.yml

This file was deleted.

29 changes: 27 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var (
FileLocation string
HistoryLocation string
PromptText = panes.PromptText
SelectedModel = panes.Selected
)

func init() {
Expand All @@ -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)
}

Expand All @@ -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()
Expand All @@ -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) {
Expand All @@ -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.")
Expand Down
4 changes: 2 additions & 2 deletions panes/modelsPane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
})
Expand Down
5 changes: 3 additions & 2 deletions panes/outputPane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down