Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
926ffa7f
"server/vscode:/vscode.git/clone" did not exist on "8642250602bf9d0cf0fd7312f3e643458f3b3e09"
Commit
926ffa7f
authored
Jul 06, 2023
by
Bruce MacDonald
Committed by
Jeffrey Morgan
Jul 06, 2023
Browse files
refactor cmd
parent
4a36f374
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
25 deletions
+10
-25
cmd/cmd.go
cmd/cmd.go
+10
-25
No files found.
cmd/cmd.go
View file @
926ffa7f
...
...
@@ -14,36 +14,17 @@ import (
"github.com/spf13/cobra"
)
func
sockpath
()
string
{
func
cacheDir
()
string
{
home
,
err
:=
os
.
UserHomeDir
()
if
err
!=
nil
{
panic
(
err
)
}
return
path
.
Join
(
home
,
".ollama"
,
"ollama.sock"
)
}
func
running
()
bool
{
// Set a timeout duration
timeout
:=
time
.
Second
// Dial the unix socket
conn
,
err
:=
net
.
DialTimeout
(
"unix"
,
sockpath
(),
timeout
)
if
err
!=
nil
{
return
false
}
if
conn
!=
nil
{
defer
conn
.
Close
()
}
return
true
return
path
.
Join
(
home
,
".ollama"
)
}
func
serve
()
error
{
sp
:=
sockpath
()
if
err
:=
os
.
MkdirAll
(
path
.
Dir
(
sp
),
0
o700
);
err
!=
nil
{
return
err
}
sp
:=
path
.
Join
(
cacheDir
(),
"ollama.sock"
)
if
err
:=
os
.
RemoveAll
(
sp
);
err
!=
nil
{
return
err
...
...
@@ -99,6 +80,10 @@ func NewCLI() *cobra.Command {
PersistentPreRun
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
// Disable usage printing on errors
cmd
.
SilenceUsage
=
true
// create the models directory and it's parent
if
err
:=
os
.
MkdirAll
(
path
.
Join
(
cacheDir
(),
"models"
),
0
o700
);
err
!=
nil
{
panic
(
err
)
}
},
}
...
...
@@ -108,7 +93,7 @@ func NewCLI() *cobra.Command {
Use
:
"run MODEL"
,
Short
:
"Run a model"
,
Args
:
cobra
.
ExactArgs
(
1
),
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
return
nil
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment