-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: support multiple generative models (#29)
- Loading branch information
Showing
8 changed files
with
148 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cli | ||
|
||
import ( | ||
"slices" | ||
|
||
"github.com/manifoldco/promptui" | ||
) | ||
|
||
var ( | ||
inputMode = []string{"single-line", "multi-line"} | ||
) | ||
|
||
// selectModel returns the selected generative model name. | ||
func selectModel(current string, models []string) (string, error) { | ||
prompt := promptui.Select{ | ||
Label: "Select generative model", | ||
HideSelected: true, | ||
Items: models, | ||
CursorPos: slices.Index(models, current), | ||
} | ||
|
||
_, result, err := prompt.Run() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return result, nil | ||
} | ||
|
||
// selectInputMode returns true if multiline input is selected; | ||
// otherwise, it returns false. | ||
func selectInputMode(multiline bool) (bool, error) { | ||
var cursorPos int | ||
if multiline { | ||
cursorPos = 1 | ||
} | ||
|
||
prompt := promptui.Select{ | ||
Label: "Select input mode", | ||
HideSelected: true, | ||
Items: inputMode, | ||
CursorPos: cursorPos, | ||
} | ||
|
||
_, result, err := prompt.Run() | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return result == inputMode[1], nil | ||
} |