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
orangecat
ollama
Commits
6137b127
"git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "d3156f76adb15091883f1e9783e0f0c33a684802"
Commit
6137b127
authored
Sep 21, 2023
by
Michael Yang
Browse files
validate existence and pull model using api
parent
1fabba47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
20 deletions
+12
-20
cmd/cmd.go
cmd/cmd.go
+12
-20
No files found.
cmd/cmd.go
View file @
6137b127
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"io"
"io"
"log"
"log"
"net"
"net"
"net/http"
"os"
"os"
"os/exec"
"os/exec"
"path/filepath"
"path/filepath"
...
@@ -108,35 +107,28 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
...
@@ -108,35 +107,28 @@ func CreateHandler(cmd *cobra.Command, args []string) error {
}
}
func
RunHandler
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
RunHandler
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
insecure
,
err
:=
cmd
.
Flags
()
.
GetBool
(
"insecure"
)
client
,
err
:=
api
.
FromEnv
(
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
mp
:=
server
.
ParseModelPath
(
args
[
0
])
models
,
err
:=
client
.
List
(
context
.
Background
())
if
mp
.
ProtocolScheme
==
"http"
&&
!
insecure
{
return
fmt
.
Errorf
(
"insecure protocol http"
)
}
fp
,
err
:=
mp
.
GetManifestPath
(
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
_
,
err
=
os
.
Stat
(
fp
)
modelName
,
modelTag
,
ok
:=
strings
.
Cut
(
args
[
0
],
":"
)
switch
{
if
!
ok
{
case
errors
.
Is
(
err
,
os
.
ErrNotExist
)
:
modelTag
=
"latest"
if
err
:=
pull
(
args
[
0
],
insecure
);
err
!=
nil
{
}
var
apiStatusError
api
.
StatusError
if
!
errors
.
As
(
err
,
&
apiStatusError
)
{
return
err
}
if
apiStatusError
.
StatusCode
!=
http
.
StatusBadGateway
{
for
_
,
model
:=
range
models
.
Models
{
return
err
if
model
.
Name
==
strings
.
Join
([]
string
{
modelName
,
modelTag
},
":"
)
{
}
return
RunGenerate
(
cmd
,
args
)
}
}
case
err
!=
nil
:
}
if
err
:=
PullHandler
(
cmd
,
args
);
err
!=
nil
{
return
err
return
err
}
}
...
...
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