Skip to content

Commit

Permalink
feat: docker ollama run
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed Jun 10, 2024
1 parent 399f1d9 commit d0718ae
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
func runModel(model string, cfg *config.Config) tea.Cmd {
// if config is set to run in docker container, run the mode using runDocker
if cfg.DockerContainer != "" && cfg.DockerContainer != "false" {
return runDocker(strings.Split(model, " "), cfg.DockerContainer)
return runDocker(cfg.DockerContainer, model)
}

ollamaPath, err := exec.LookPath("ollama")
Expand All @@ -38,16 +38,15 @@ func runModel(model string, cfg *config.Config) tea.Cmd {
})
}

func runDocker(params []string, container string) tea.Cmd {
func runDocker(container string, model string) tea.Cmd {
dockerPath, err := exec.LookPath("docker")
if err != nil {
logging.ErrorLogger.Printf("Error finding docker binary: %v\n", err)
return nil
}

// parse the params into a list of arguments to supply to docker exec
args := []string{"exec", container, "ollama"}
args = append(args, params...)
args := []string{"exec", "-it", container, "ollama", "run", model}

c := exec.Command(dockerPath, args...)
return tea.ExecProcess(c, func(err error) tea.Msg {
Expand Down

0 comments on commit d0718ae

Please sign in to comment.