Skip to content

Commit

Permalink
fix: version string, improve error handling (#52)
Browse files Browse the repository at this point in the history
* fix: improve error handling

* fix: version string
  • Loading branch information
sammcj authored Jun 21, 2024
1 parent c6205d4 commit 70e0f28
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5
with:
go-version: 1.22.3
go-version-file: "go.mod"
- run: go version

# Install dependencies
- name: Install dependencies
run: go mod download
run: go get .

# Get the version we're building
- name: Get version
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ help: ## This help function
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

clean: ## Clean
rm -rf ./dist
rm -rf ./dist gollama*.zip gollama *.log

debug-server: ## Debug server
dlv debug --headless --api-version=2 --listen=127.0.0.1:43000 .
Expand All @@ -63,17 +63,17 @@ test: ## Run test
build: ## Run build
$(eval GOLLAMA_VERSION := $(shell if [ -z "$(GOLLAMA_VERSION)" ]; then echo "dev"; else echo "$(GOLLAMA_VERSION)"; fi))
@echo "Building with version: $(GOLLAMA_VERSION)"
go build -v -ldflags "-X 'main.Version=$(GOLLAMA_VERSION)'"
go build -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'"
@echo "Build completed, run ./gollama"

ci: ## build for linux and macOS
$(eval GOLLAMA_VERSION := $(shell if [ -z "$(GOLLAMA_VERSION)" ]; then echo "dev"; else echo $(GOLLAMA_VERSION); fi))
@echo "Building with version: $(GOLLAMA_VERSION)"

mkdir -p ./dist/macos ./dist/linux_amd64 ./dist/linux_arm64
GOOS=darwin GOARCH=arm64 go build -v -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'" -o ./dist/macos/
GOOS=linux GOARCH=amd64 go build -v -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'" -o ./dist/linux_amd64/
GOOS=linux GOARCH=arm64 go build -v -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'" -o ./dist/linux_arm64/
GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'" -o ./dist/macos/
GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'" -o ./dist/linux_amd64/
GOOS=linux GOARCH=arm64 go build -ldflags="-X 'main.Version=$(GOLLAMA_VERSION)'" -o ./dist/linux_arm64/

# zip up each build
zip -r gollama-macos.zip ./dist/macos/gollama
Expand Down
4 changes: 2 additions & 2 deletions app_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ func (m *AppModel) handleRunModelKey() (tea.Model, tea.Cmd) {

func (m *AppModel) handleAltScreenKey() (tea.Model, tea.Cmd) {
logging.DebugLogger.Println("AltScreen key matched")
m.altscreenActive = !m.altscreenActive
m.altScreenActive = !m.altScreenActive
cmd := tea.EnterAltScreen
if !m.altscreenActive {
if !m.altScreenActive {
cmd = tea.ExitAltScreen
}
return m, cmd
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/bubbles v0.18.0 h1:PYv1A036luoBGroX6VWjQIE9Syf2Wby2oOl/39KLfy0=
github.com/charmbracelet/bubbles v0.18.0/go.mod h1:08qhZhtIwzgrtBjAcJnij1t1H0ZRjwHyGsy6AL11PSw=
github.com/charmbracelet/bubbletea v0.26.4 h1:2gDkkzLZaTjMl/dQBpNVtnvcCxsh/FCkimep7FC9c40=
github.com/charmbracelet/bubbletea v0.26.4/go.mod h1:P+r+RRA5qtI1DOHNFn0otoNwB4rn+zNAzSj/EXz6xU0=
github.com/charmbracelet/bubbletea v0.26.5 h1:90pqTPElAReb/qQUgSMUresTkfwVr0Wx+zczeHHOgxk=
github.com/charmbracelet/bubbletea v0.26.5/go.mod h1:dz8CWPlfCCGLFbBlTY4N7bjLiyOGDJEnd2Muu7pOWhk=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
Expand Down Expand Up @@ -53,8 +51,6 @@ github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
github.com/ollama/ollama v0.1.44 h1:3Htzf/mn0nNn1oBOm3rdnbSfX6dOTpOW0YRnxYTsqbo=
github.com/ollama/ollama v0.1.44/go.mod h1:TvVa25PEZI6M0bosiW1sa2XJGq3Xw/OPlpUAkMEntTU=
github.com/ollama/ollama v0.1.45 h1:kwXM83GKToTnueX5zJHqRvwLy1/zzYw8C0sO60wOKqA=
github.com/ollama/ollama v0.1.45/go.mod h1:TvVa25PEZI6M0bosiW1sa2XJGq3Xw/OPlpUAkMEntTU=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
7 changes: 2 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ type AppModel struct {
filterInput tea.Model
showTop bool
progress progress.Model
altscreenActive bool
altScreenActive bool
view View
showProgress bool
needsRefresh bool
}

type progressMsg struct {
Expand All @@ -69,9 +68,7 @@ type genericMsg struct {
message string
}

var (
Version string // Version will be set during the build process
)
var Version = "development" // Version is set by the build system

func main() {
cfg, err := config.LoadConfig()
Expand Down
1 change: 1 addition & 0 deletions operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func runModel(model string, cfg *config.Config) tea.Cmd {
ollamaPath, err := exec.LookPath("ollama")
if err != nil {
logging.ErrorLogger.Printf("Error finding ollama binary: %v\n", err)
logging.ErrorLogger.Printf("If you're running Ollama in a container, make sure you updated the config file with the container name\n")
return nil
}
c := exec.Command(ollamaPath, "run", model)
Expand Down

0 comments on commit 70e0f28

Please sign in to comment.