@@ -20,12 +20,11 @@ import (
20
20
)
21
21
22
22
var (
23
- ollamaLong = "Start an AI/ML model workspace with specified model types"
23
+ ollamaLong = "Start an Ollama server with specified model types"
24
24
ollamaExample = `
25
25
brev ollama --model llama3
26
- brev ollama --model mistral7b
27
26
`
28
- modelTypes = []string {"llama2" , " llama3" , "mistral7b " }
27
+ modelTypes = []string {"llama3" }
29
28
)
30
29
31
30
//go:embed ollamaverb.yaml
@@ -38,7 +37,7 @@ type OllamaStore interface {
38
37
CreateWorkspace (organizationID string , options * store.CreateWorkspacesOptions ) (* entity.Workspace , error )
39
38
GetWorkspace (workspaceID string ) (* entity.Workspace , error )
40
39
BuildVerbContainer (workspaceID string , verbYaml string ) (* store.BuildVerbRes , error )
41
- ModifyPublicity (workspace * entity.Workspace , publicity bool ) (* entity.Tunnel , error )
40
+ ModifyPublicity (workspace * entity.Workspace , applicationName string , publicity bool ) (* entity.Tunnel , error )
42
41
}
43
42
44
43
func validateModelType (modelType string ) bool {
@@ -188,12 +187,18 @@ func runOllamaWorkspace(t *terminal.Terminal, model string, ollamaStore OllamaSt
188
187
189
188
s .Stop ()
190
189
191
- link , err := getOllamaTunnelLink (w , ollamaStore )
190
+ // Reload workspace to get the latest status
191
+ w , err = ollamaStore .GetWorkspace (w .ID )
192
192
if err != nil {
193
193
return breverrors .WrapAndTrace (err )
194
194
}
195
195
196
- _ , err = makeTunnelPublic (w , ollamaStore )
196
+ link , name , err := getOllamaTunnelLink (w )
197
+ if err != nil {
198
+ return breverrors .WrapAndTrace (err )
199
+ }
200
+
201
+ _ , err = makeTunnelPublic (w , name , ollamaStore )
197
202
if err != nil {
198
203
return breverrors .WrapAndTrace (err )
199
204
}
@@ -224,7 +229,7 @@ func pollInstanceUntilVMReady(workspace *entity.Workspace, interval time.Duratio
224
229
time .Sleep (interval )
225
230
elapsedTime += interval
226
231
}
227
- return false , breverrors .New ("timeout waiting for instance to start" )
232
+ return false , breverrors .New ("Timeout waiting for machine to start" )
228
233
}
229
234
230
235
func pollInstanceUntilVerbContainerReady (workspace * entity.Workspace , interval time.Duration , timeout time.Duration , ollamaStore OllamaStore ) (bool , error ) {
@@ -240,29 +245,25 @@ func pollInstanceUntilVerbContainerReady(workspace *entity.Workspace, interval t
240
245
time .Sleep (interval )
241
246
elapsedTime += interval
242
247
}
243
- return false , breverrors .New ("timeout waiting for instance to start " )
248
+ return false , breverrors .New ("Timeout waiting for container to build " )
244
249
}
245
250
246
- func getOllamaTunnelLink (workspace * entity.Workspace , ollamaStore OllamaStore ) (string , error ) {
247
- w , err := ollamaStore .GetWorkspace (workspace .ID )
248
- if err != nil {
249
- return "" , breverrors .WrapAndTrace (err )
250
- }
251
- for _ , v := range w .Tunnel .Applications {
251
+ func getOllamaTunnelLink (workspace * entity.Workspace ) (string , string , error ) {
252
+ for _ , v := range workspace .Tunnel .Applications {
252
253
if v .Port == 11434 {
253
- return v .Hostname , nil
254
+ return v .Hostname , v . Name , nil
254
255
}
255
256
}
256
- return "" , breverrors .New ("Could not find Ollama tunnel" )
257
+ return "" , "" , breverrors .New ("Could not find Ollama tunnel" )
257
258
}
258
259
259
- // TODO: stubs for granular permissioning
260
+ // TODO: stub for granular permissioning
260
261
// func generateCloudflareAPIKeys(workspace *entity.Workspace, ollamaStore OllamaStore) (bool, error) {
261
262
// return false, nil
262
263
// }
263
264
264
- func makeTunnelPublic (workspace * entity.Workspace , ollamaStore OllamaStore ) (bool , error ) {
265
- t , err := ollamaStore .ModifyPublicity (workspace , true )
265
+ func makeTunnelPublic (workspace * entity.Workspace , applicationName string , ollamaStore OllamaStore ) (bool , error ) {
266
+ t , err := ollamaStore .ModifyPublicity (workspace , applicationName , true )
266
267
if err != nil {
267
268
return false , breverrors .WrapAndTrace (err )
268
269
}
0 commit comments