Skip to content

Commit

Permalink
35: fixes for issues revealed by e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufcanb committed Feb 9, 2025
1 parent daec901 commit 766fc79
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pkg/app/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func beforeRun(o *ollama.Client) func(c *cli.Context) error {
arg := c.Args().Get(0)

// If the command is suggest or explain, check if Ollama is set and up
if arg == "suggest" || arg == "s" || arg == "explain" || arg == "e" {
if arg == "suggest" || arg == "s" || arg == "explain" || arg == "e" || arg == "ask" || arg == "a" {

var err error

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func (c *Config) subCommandSet() *cli.Command {
}
viper.Set(shellKey, s)

case llmModelKey:
s := c.Args().Get(1)
viper.Set(llmModelKey, s)

default:
fmt.Println(fmt.Sprintf("%s <%s> is not a tlm parameter", shell.Err(), key))
return nil
Expand Down
16 changes: 4 additions & 12 deletions pkg/packer/internal/exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ var defaultIgnoreList = []string{
"**/bun.lockb",
"**/__pycache__/**",
"**/*.py[cod]",
"**/venv/**",
"**/.venv/**",
"venv/**",
"**/venv",
".venv/**",
"**/.venv",
"**/.pytest_cache/**",
"**/.mypy_cache/**",
"**/.ipynb_checkpoints/**",
Expand All @@ -89,13 +91,3 @@ var defaultIgnoreList = []string{
"**/stack.yaml.lock",
"**/cabal.project.freeze",
}

// shouldExclude returns true if the file path matches any of the exclude patterns.
// func shouldExclude(path string, patterns []string) bool {
// for _, pattern := range patterns {
// if match, _ := doublestar.Match(pattern, filepath.ToSlash(path)); match {
// return true
// }
// }
// return false
// }
9 changes: 4 additions & 5 deletions pkg/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func Exec2(command string) (*exec.Cmd, *bytes.Buffer, *bytes.Buffer) {
func CheckOllamaIsUp(api *ollama.Client) error {
_, err := api.Version(context.Background())
if err != nil {
fmt.Println(Err() + " " + err.Error())
fmt.Println(Err() + " Ollama connection failed. Please check your Ollama if it's running or configured correctly.")
fmt.Printf(Err()+" Ollama connection failed. Please check your Ollama if it's running or configured correctly. \n%s", err.Error())
os.Exit(-1)
}
return nil
Expand All @@ -82,18 +81,18 @@ func CheckOllamaIsUp(api *ollama.Client) error {
func CheckOllamaIsSet() error {
host := os.Getenv("OLLAMA_HOST")
if host == "" {
return fmt.Errorf("OLLAMA_HOST environment variable is not set")
return fmt.Errorf(Err() + " OLLAMA_HOST environment variable is not set.")
}

// parse url
u, err := url.Parse(host)
if err != nil {
return fmt.Errorf("invalid OLLAMA_HOST URL: %v", err)
return fmt.Errorf(Err()+" invalid OLLAMA_HOST URL: %v", err)
}

// check if scheme is http or https
if u.Scheme != "http" && u.Scheme != "https" {
return fmt.Errorf(" OLLAMA_HOST must use http or https protocol")
return fmt.Errorf(Err() + "OLLAMA_HOST must use http or https protocol.")
}

return nil
Expand Down

0 comments on commit 766fc79

Please sign in to comment.