Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ollama: implement ollama with llama3 command #188

Merged
merged 32 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
96062ef
ollama: Add start of ollama subcommand
tmc Apr 29, 2024
6f6db45
cmd: remove unused setup subcommand directory
tmc Apr 29, 2024
8d90a1f
open: Clean up help message
tmc Apr 29, 2024
1a448db
ollama: Mark as a quickstart
tmc Apr 29, 2024
8f90450
make move tools target name
tmc Apr 29, 2024
0f4c6ec
make: Add install-dev target to install the brev cli locally
tmc Apr 29, 2024
013b5e1
cmd: cleanup helpers
tmc Apr 29, 2024
c169c2b
tools: Fix up tools management/handling
tmc Apr 29, 2024
fab3493
init files for ollama command
naderkhalil Apr 29, 2024
4a202d4
ollama cmd
naderkhalil Apr 29, 2024
713dfd4
ollama cmd stuff
naderkhalil Apr 29, 2024
2290844
updates
naderkhalil Apr 29, 2024
b9960ec
fixup
tmc Apr 29, 2024
2125a32
cli: Fix up quickstart commands
tmc Apr 29, 2024
fe7e408
ollama: use default cluster id
tmc Apr 29, 2024
3d8a1d2
ollama: default to a T4
tmc Apr 29, 2024
257dcf7
cli: add debug flag behind env var
tmc Apr 12, 2024
cd29d3a
ollama: Start verb yaml
tmc Apr 30, 2024
839ad40
delete: Fix delete command with ids
tmc Apr 30, 2024
9b03b0d
ollama: Add start of verb build call
tmc May 2, 2024
89efbfa
adding buildverb call and ollama debugger
ishandhanani May 3, 2024
c19de3c
adding polling before verb build
ishandhanani May 3, 2024
8dfbbe3
working brev ollama command
ishandhanani May 5, 2024
83ef69c
working implementation
ishandhanani May 7, 2024
5c14557
proper verb yaml
ishandhanani May 7, 2024
4c3a6fd
update ollama embedded verb
ishandhanani May 7, 2024
3782881
initial cloudflare types
ishandhanani May 7, 2024
7a6929b
adding modify endpoint
ishandhanani May 7, 2024
7e2abd4
cloudflare publicity endpoints
ishandhanani May 8, 2024
02e8ebf
cleanup
ishandhanani May 8, 2024
d65d89e
cloudflare public works
ishandhanani May 9, 2024
f1c3080
fix linting, use async
theFong May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,19 @@
"updatemodel",
],
},
{
"name": "ollama",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
// "envFile": "${workspaceFolder}/prod_lite.env",
// "envFile": "${workspaceFolder}/local.env",
"args": [
"ollama",
"--model",
"llama2",
],
}
]
}
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ fast-build: ## go build -o brev
echo ${VERSION}
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"

.PHONY: install-dev
install-dev: fast-build ## go install
cp brev $(shell go env GOPATH)/bin/

.PHONY: version
version:
echo ${VERSION}

.PHONY: dev
dev: ## dev build
dev: clean install generate vet fmt lint test mod-tidy
dev: clean install-tools generate vet fmt lint test mod-tidy

.PHONY: ci
ci: ## CI build
Expand All @@ -25,10 +29,10 @@ clean: ## remove files created during build pipeline
rm -rf dist
rm -f coverage.*

.PHONY: install
install: ## go install tools
.PHONY: install-tools
install-tools: ## go install tools
$(call print-target)
cd tools && go install $(shell cd tools && go list -f '{{ join .Imports " " }}' -tags=tools)
cd tools && go install $(shell cd tools && go list -e -f '{{ join .Imports " " }}' -tags=tools)

.PHONY: generate
generate: ## go generate
Expand Down Expand Up @@ -80,13 +84,13 @@ diff: ## git diff

.PHONY: build
build: ## goreleaser --snapshot --skip-publish --rm-dist
build: install
build: install-tools
$(call print-target)
goreleaser --snapshot --skip-publish --rm-dist

.PHONY: release
release: ## goreleaser --rm-dist
release: install
release: install-tools
$(call print-target)
goreleaser --rm-dist

Expand Down Expand Up @@ -273,4 +277,4 @@ new-cmd:

.PHONY: develop-with-nix
develop-with-nix:
nix develop .
nix develop .
85 changes: 47 additions & 38 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/brevdev/brev-cli/pkg/cmd/logout"
"github.com/brevdev/brev-cli/pkg/cmd/ls"
"github.com/brevdev/brev-cli/pkg/cmd/notebook"
"github.com/brevdev/brev-cli/pkg/cmd/ollama"
"github.com/brevdev/brev-cli/pkg/cmd/open"
"github.com/brevdev/brev-cli/pkg/cmd/optimizeinstances"
"github.com/brevdev/brev-cli/pkg/cmd/org"
"github.com/brevdev/brev-cli/pkg/cmd/portforward"
"github.com/brevdev/brev-cli/pkg/cmd/postinstall"
Expand Down Expand Up @@ -97,7 +97,7 @@ func NewBrevCommand() *cobra.Command { //nolint:funlen,gocognit,gocyclo // defin
loginCmdStore := fsStore.WithNoAuthHTTPClient(
store.NewNoAuthHTTPClient(conf.GetBrevAPIURl()),
).
WithAuth(loginAuth)
WithAuth(loginAuth, store.WithDebug(conf.GetDebugHTTP()))

err := loginCmdStore.SetForbiddenStatusRetryHandler(func() error {
_, err1 := loginAuth.GetAccessToken()
Expand Down Expand Up @@ -207,19 +207,18 @@ func NewBrevCommand() *cobra.Command { //nolint:funlen,gocognit,gocyclo // defin
},
}
cobra.AddTemplateFunc("hasContextCommands", hasContextCommands)
cobra.AddTemplateFunc("isContextCommand", isContextCommand)
cobra.AddTemplateFunc("contextCommands", contextCommands)
cobra.AddTemplateFunc("hasSSHCommands", hasSSHCommands)
cobra.AddTemplateFunc("isSSHCommand", isSSHCommand)
cobra.AddTemplateFunc("sshCommands", sshCommands)
cobra.AddTemplateFunc("hasWorkspaceCommands", hasWorkspaceCommands)
cobra.AddTemplateFunc("isWorkspaceCommand", isWorkspaceCommand)
cobra.AddTemplateFunc("workspaceCommands", workspaceCommands)
cobra.AddTemplateFunc("hasHousekeepingCommands", hasHousekeepingCommands)
cobra.AddTemplateFunc("hasDebugCommands", hasDebugCommands)
cobra.AddTemplateFunc("debugCommands", debugCommands)
cobra.AddTemplateFunc("printCautiousMetaCmdMessage", printCautiousMetaCmdMessage)
cobra.AddTemplateFunc("isHousekeepingCommand", isHousekeepingCommand)
cobra.AddTemplateFunc("housekeepingCommands", housekeepingCommands)
cobra.AddTemplateFunc("hasQuickstartCommands", hasQuickstartCommands)
cobra.AddTemplateFunc("quickstartCommands", quickstartCommands)

cmds.SetUsageTemplate(usageTemplate)

Expand Down Expand Up @@ -263,14 +262,13 @@ func createCmdTree(cmd *cobra.Command, t *terminal.Terminal, loginCmdStore *stor
cmd.AddCommand(importideconfig.NewCmdImportIDEConfig(t, noLoginCmdStore))
cmd.AddCommand(shell.NewCmdShell(t, loginCmdStore, noLoginCmdStore))
cmd.AddCommand(open.NewCmdOpen(t, loginCmdStore, noLoginCmdStore))
cmd.AddCommand(optimizeinstances.NewCmdOptimizeInstances(t, loginCmdStore))
cmd.AddCommand(optimizeinstances.NewCmdOptimize(t, loginCmdStore))

cmd.AddCommand(ollama.NewCmdOllama(t, loginCmdStore))
cmd.AddCommand(background.NewCmdBackground(t, loginCmdStore))
cmd.AddCommand(status.NewCmdStatus(t, loginCmdStore))
cmd.AddCommand(secret.NewCmdSecret(loginCmdStore, t))
cmd.AddCommand(sshkeys.NewCmdSSHKeys(t, loginCmdStore))
cmd.AddCommand(start.NewCmdStart(t, loginCmdStore, noLoginCmdStore))
cmd.AddCommand(start.NewCmdStart(t, loginCmdStore, noLoginCmdStore))
cmd.AddCommand(create.NewCmdCreate(t, loginCmdStore))
cmd.AddCommand(stop.NewCmdStop(t, loginCmdStore, noLoginCmdStore))
cmd.AddCommand(delete.NewCmdDelete(t, loginCmdStore, noLoginCmdStore))
Expand All @@ -293,12 +291,16 @@ func createCmdTree(cmd *cobra.Command, t *terminal.Terminal, loginCmdStore *stor
cmd.AddCommand(updatemodel.NewCmdupdatemodel(t, loginCmdStore))
}

func hasQuickstartCommands(cmd *cobra.Command) bool {
return len(quickstartCommands(cmd)) > 0
}

func hasHousekeepingCommands(cmd *cobra.Command) bool {
return len(housekeepingCommands(cmd)) > 0
}

func hasDebugCommands(cmd *cobra.Command) bool {
return len(debugsCommands(cmd)) > 0
return len(debugCommands(cmd)) > 0
}

func printCautiousMetaCmdMessage() string {
Expand All @@ -318,6 +320,16 @@ func hasContextCommands(cmd *cobra.Command) bool {
return len(contextCommands(cmd)) > 0
}

func quickstartCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
for _, sub := range cmd.Commands() {
if isQuickstartCommand(sub) {
cmds = append(cmds, sub)
}
}
return cmds
}

func housekeepingCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
for _, sub := range cmd.Commands() {
Expand All @@ -328,7 +340,7 @@ func housekeepingCommands(cmd *cobra.Command) []*cobra.Command {
return cmds
}

func debugsCommands(cmd *cobra.Command) []*cobra.Command {
func debugCommands(cmd *cobra.Command) []*cobra.Command {
cmds := []*cobra.Command{}
for _, sub := range cmd.Commands() {
if isDebugCommand(sub) {
Expand Down Expand Up @@ -368,44 +380,34 @@ func contextCommands(cmd *cobra.Command) []*cobra.Command {
return cmds
}

func isQuickstartCommand(cmd *cobra.Command) bool {
_, ok := cmd.Annotations["quickstart"]
return ok
}

func isHousekeepingCommand(cmd *cobra.Command) bool {
if _, ok := cmd.Annotations["housekeeping"]; ok {
return true
} else {
return false
}
_, ok := cmd.Annotations["housekeeping"]
return ok
}

func isDebugCommand(cmd *cobra.Command) bool {
if _, ok := cmd.Annotations["debug"]; ok {
return true
} else {
return false
}
_, ok := cmd.Annotations["debug"]
return ok
}

func isSSHCommand(cmd *cobra.Command) bool {
if _, ok := cmd.Annotations["ssh"]; ok {
return true
} else {
return false
}
_, ok := cmd.Annotations["ssh"]
return ok
}

func isWorkspaceCommand(cmd *cobra.Command) bool {
if _, ok := cmd.Annotations["workspace"]; ok {
return true
} else {
return false
}
_, ok := cmd.Annotations["workspace"]
return ok
}

func isContextCommand(cmd *cobra.Command) bool {
if _, ok := cmd.Annotations["context"]; ok {
return true
} else {
return false
}
_, ok := cmd.Annotations["context"]
return ok
}

var usageTemplate = `Usage:{{if .Runnable}}
Expand Down Expand Up @@ -439,6 +441,13 @@ SSH Commands:
{{rpad .Name .NamePadding }} {{.Short}}
{{- end}}{{- end}}

{{- if hasQuickstartCommands . }}

Quickstart Commands:
{{- range quickstartCommands . }}
{{rpad .Name .NamePadding }} {{.Short}}
{{- end}}{{- end}}

{{- if hasHousekeepingCommands . }}

Housekeeping Commands:
Expand All @@ -448,8 +457,8 @@ Housekeeping Commands:

{{- if hasDebugCommands . }}

Housekeeping Commands:
{{- range housekeepingCommands . }}
Debug Commands:
{{- range debugCommands . }}
{{rpad .Name .NamePadding }} {{.Short}}
{{- end}}{{- end}}

Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/envsetup/envsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ logs:
stringToAppend := fmt.Sprintf("\nlogs_enabled: true\nhostname: %s\n", hostname)
// add logs_enabled: true to /etc/datadog-agent/datadog.yaml
err = e.store.AppendString("/etc/datadog-agent/datadog.yaml", stringToAppend)

if err != nil {
return breverrors.WrapAndTrace(err)
}
Expand Down
Loading
Loading