-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0254bd9
Showing
8 changed files
with
1,090 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Build and release | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
paths: | ||
- 'main.go' | ||
- 'go.mod' | ||
- '.github/workflows/build-and-release.yml' | ||
tags: | ||
- v* | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
checks: write | ||
pull-requests: write | ||
packages: write | ||
|
||
concurrency: | ||
group: build-and-release | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-and-release: | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | ||
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 | ||
with: | ||
go-version: 1.22.1 | ||
|
||
# Install dependencies | ||
- name: Install dependencies | ||
run: go mod download | ||
|
||
# Build | ||
- name: Build macOS ARM64 | ||
run: | | ||
GOOS=darwin GOARCH=arm64 go build -o main.go -o gollama-macos-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
echo "macOS ARM64 build completed" >> "$GITHUB_STEP_SUMMARY" | ||
- name: Build Linux | ||
run: | | ||
GOOS=linux GOARCH=amd64 go build -o main.go -o gollama-linux-amd64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
GOOS=linux GOARCH=arm64 go build -o main.go -o gollama-linux-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
echo "Linux build completed" >> "$GITHUB_STEP_SUMMARY" | ||
- name: Upload artefacts | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4 | ||
with: | ||
name: gollama | ||
path: | | ||
gollama-macos-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
gollama-linux-amd64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
gollama-linux-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
# Bump version | ||
- name: Bump version and push tag | ||
id: tag_version | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') && !contains(github.event.head_commit.message, '[skip ci]') | ||
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
release_branches: main | ||
pre_release_branches: dev | ||
|
||
# Publish | ||
- name: Create a GitHub release | ||
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1 | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') && !contains(github.event.head_commit.message, '[skip ci]') | ||
with: | ||
tag: ${{ steps.tag_version.outputs.new_tag }} | ||
name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
generateReleaseNotes: true | ||
allowUpdates: true | ||
prerelease: ${{ startsWith(github.ref, 'refs/heads/dev') }} | ||
artifacts: | | ||
gollama-macos-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
gollama-linux-amd64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
gollama-linux-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,6 @@ | ||
gollama | ||
**/.swp | ||
**/.tmp | ||
**/.trash | ||
**/*.log | ||
dist/ |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Sam McLeod | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,231 @@ | ||
# gollama - Go manage your Ollama models | ||
|
||
gollama is a TUI application to help manage your Ollama models. It provides an interactive way to view, sort, run, and delete your models. | ||
|
||
## Features | ||
|
||
- List all available models with details such as name, ID, size, quantisation level, and modified date. | ||
- Sort models by name, size, or modified date. | ||
- Select multiple models for deletion. | ||
- Run a selected model using the Ollama CLI. | ||
- Logging to `gollama.log` file with debug, info, and error levels. | ||
|
||
## Installation | ||
|
||
1. Ensure you have Go installed on your system. | ||
2. Clone this repository: | ||
|
||
```bash | ||
git clone https://github.com/yourusername/gollama.git | ||
``` | ||
|
||
3. Navigate to the project directory: | ||
|
||
```bash | ||
cd gollama | ||
``` | ||
|
||
4. Build the application: | ||
|
||
```bash | ||
go build -o gollama main.go | ||
``` | ||
|
||
## Usage | ||
|
||
Run the application: | ||
|
||
```bash | ||
gollama | ||
``` | ||
|
||
Use the following keyboard shortcuts to interact with the TUI: | ||
|
||
| Key | Action | | ||
| ----- | ----------------------- | | ||
| Space | Select/deselect a model | | ||
| D | Delete selected models | | ||
| s | Sort by name | | ||
| S | Sort by size | | ||
| m | Sort by modified date | | ||
| Enter | Run the selected model | | ||
| y | Confirm deletion | | ||
| n | Cancel deletion | | ||
|
||
## Architecture | ||
|
||
_Current as of 2024-05-30_ | ||
|
||
Component Diagram (PlantUML): | ||
|
||
```plantuml | ||
@startuml | ||
title Gollama Application Component Diagram | ||
component "Main Package" { | ||
[AppModel] | ||
[main] | ||
} | ||
component "Ollama API Client" { | ||
[api.Client] | ||
} | ||
component "Bubbletea Library" { | ||
interface tea.Model <<interface>> | ||
} | ||
component "Charmbracelet Bubbles" { | ||
[list.Model] | ||
[key.Binding] | ||
} | ||
[AppModel] --> [api.Client]: Uses for API calls | ||
[AppModel] --> [list.Model]: Displays model data | ||
[KeyMap] --> [list.Model]: Handles user input | ||
[tea.Program] -down-> [AppModel]: Manages the application's state | ||
@enduml | ||
``` | ||
|
||
Class Diagram (PlantUML): | ||
|
||
```plantuml | ||
@startuml | ||
title Gollama Application Class Diagram | ||
class Model { | ||
- Name: string | ||
- ID: string | ||
- Size: float64 | ||
- QuantizationLevel: string | ||
- Modified: time.Time | ||
- Selected: bool | ||
+ Title(): string | ||
+ Description(): string | ||
+ FilterValue(): string | ||
} | ||
class KeyMap { | ||
- Space: key.Binding | ||
- Delete: key.Binding | ||
- SortByName: key.Binding | ||
- SortBySize: key.Binding | ||
- SortByModified: key.Binding | ||
- RunModel: key.Binding | ||
- ConfirmYes: key.Binding | ||
- ConfirmNo: key.Binding | ||
} | ||
class AppModel { | ||
- client: *api.Client | ||
- list: list.Model | ||
- keys: *KeyMap | ||
- models: []Model | ||
- width: int | ||
- height: int | ||
- confirmDeletion: bool | ||
- selectedForDeletion: []Model | ||
+ Init(): tea.Cmd | ||
+ Update(msg tea.Msg): (tea.Model, tea.Cmd) | ||
+ View(): string | ||
} | ||
class "main" { | ||
+ main(): void | ||
} | ||
AppModel --> Model: Contains | ||
AppModel --> KeyMap: Uses | ||
"main" --> AppModel: Creates and initializes | ||
@enduml | ||
``` | ||
|
||
```plantuml | ||
@startuml | ||
title Gollama Application Architecture | ||
package "Main Package" { | ||
class Model { | ||
- Name: string | ||
- ID: string | ||
- Size: float64 | ||
- QuantizationLevel: string | ||
- Modified: time.Time | ||
- Selected: bool | ||
+ Title(): string | ||
+ Description(): string | ||
+ FilterValue(): string | ||
} | ||
class KeyMap { | ||
- Space: key.Binding | ||
- Delete: key.Binding | ||
- SortByName: key.Binding | ||
- SortBySize: key.Binding | ||
- SortByModified: key.Binding | ||
- RunModel: key.Binding | ||
- ConfirmYes: key.Binding | ||
- ConfirmNo: key.Binding | ||
} | ||
class AppModel { | ||
- client: *api.Client | ||
- list: list.Model | ||
- keys: *KeyMap | ||
- models: []Model | ||
- width: int | ||
- height: int | ||
- confirmDeletion: bool | ||
- selectedForDeletion: []Model | ||
} | ||
class "main" { | ||
+ main(): void | ||
} | ||
} | ||
package "Ollama API Client" { | ||
class "api.Client" { | ||
+ List(ctx context.Context) (*ListResponse, error) | ||
+ Delete(ctx context.Context, req *DeleteRequest) error | ||
} | ||
class "ListResponse" {} | ||
class "DeleteRequest" {} | ||
} | ||
package "Bubbletea Library" { | ||
interface tea.Model { | ||
Init(): tea.Cmd | ||
Update(msg tea.Msg): (tea.Model, tea.Cmd) | ||
View(): string | ||
} | ||
} | ||
package "Charmbracelet Bubbles" { | ||
class "list.Model" {} | ||
class "key.Binding" {} | ||
} | ||
main --> AppModel: Creates and initializes | ||
AppModel --> api.Client: Uses for API calls | ||
api.Client <-- AppModel: Fetches model data | ||
AppModel --> list.Model: Displays model data | ||
list.Model <--> Model: Contains items of type Model | ||
AppModel --> KeyMap: Defines key bindings | ||
KeyMap --> list.Model: Handles user input | ||
AppModel --> "tea.Program": Runs the application | ||
"tea.Program" -down-> AppModel: Manages the application's state | ||
@enduml | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request. | ||
|
||
## License | ||
|
||
[MIT License](LICENSE) | ||
|
||
Copyright © 2024 Sam McLeod |
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,35 @@ | ||
module sammcj/gollama | ||
|
||
go 1.22.3 | ||
|
||
require ( | ||
github.com/charmbracelet/bubbles v0.18.0 | ||
github.com/charmbracelet/bubbletea v0.26.3 | ||
github.com/charmbracelet/lipgloss v0.11.0 | ||
github.com/ollama/ollama v0.1.39 | ||
golang.org/x/term v0.20.0 | ||
) | ||
|
||
require ( | ||
github.com/atotto/clipboard v0.1.4 // indirect | ||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect | ||
github.com/charmbracelet/x/ansi v0.1.2 // indirect | ||
github.com/charmbracelet/x/input v0.1.1 // indirect | ||
github.com/charmbracelet/x/term v0.1.1 // indirect | ||
github.com/charmbracelet/x/windows v0.1.2 // indirect | ||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mattn/go-localereader v0.0.1 // indirect | ||
github.com/mattn/go-runewidth v0.0.15 // indirect | ||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect | ||
github.com/muesli/cancelreader v0.2.2 // indirect | ||
github.com/muesli/reflow v0.3.0 // indirect | ||
github.com/muesli/termenv v0.15.2 // indirect | ||
github.com/rivo/uniseg v0.4.7 // indirect | ||
github.com/sahilm/fuzzy v0.1.1 // indirect | ||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
golang.org/x/text v0.15.0 // indirect | ||
) |
Oops, something went wrong.