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
7ca71a6b
Unverified
Commit
7ca71a6b
authored
May 13, 2024
by
Patrick Devine
Committed by
GitHub
May 13, 2024
Browse files
don't abort when an invalid model name is used in /save (#4416)
parent
7607e6e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
cmd/interactive.go
cmd/interactive.go
+5
-1
server/routes.go
server/routes.go
+2
-1
types/errtypes/errtypes.go
types/errtypes/errtypes.go
+1
-0
No files found.
cmd/interactive.go
View file @
7ca71a6b
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
"github.com/ollama/ollama/api"
"github.com/ollama/ollama/api"
"github.com/ollama/ollama/progress"
"github.com/ollama/ollama/progress"
"github.com/ollama/ollama/readline"
"github.com/ollama/ollama/readline"
"github.com/ollama/ollama/types/errtypes"
)
)
type
MultilineState
int
type
MultilineState
int
...
@@ -281,7 +282,10 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
...
@@ -281,7 +282,10 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
fn
:=
func
(
resp
api
.
ProgressResponse
)
error
{
return
nil
}
fn
:=
func
(
resp
api
.
ProgressResponse
)
error
{
return
nil
}
err
=
client
.
Create
(
cmd
.
Context
(),
req
,
fn
)
err
=
client
.
Create
(
cmd
.
Context
(),
req
,
fn
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"error: couldn't save model"
)
if
strings
.
Contains
(
err
.
Error
(),
errtypes
.
InvalidModelNameErrMsg
)
{
fmt
.
Printf
(
"error: The model name '%s' is invalid
\n
"
,
args
[
1
])
continue
}
return
err
return
err
}
}
fmt
.
Printf
(
"Created new model '%s'
\n
"
,
args
[
1
])
fmt
.
Printf
(
"Created new model '%s'
\n
"
,
args
[
1
])
...
...
server/routes.go
View file @
7ca71a6b
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"github.com/ollama/ollama/llm"
"github.com/ollama/ollama/llm"
"github.com/ollama/ollama/openai"
"github.com/ollama/ollama/openai"
"github.com/ollama/ollama/server/envconfig"
"github.com/ollama/ollama/server/envconfig"
"github.com/ollama/ollama/types/errtypes"
"github.com/ollama/ollama/types/model"
"github.com/ollama/ollama/types/model"
"github.com/ollama/ollama/version"
"github.com/ollama/ollama/version"
)
)
...
@@ -517,7 +518,7 @@ func (s *Server) CreateModelHandler(c *gin.Context) {
...
@@ -517,7 +518,7 @@ func (s *Server) CreateModelHandler(c *gin.Context) {
name
:=
model
.
ParseName
(
cmp
.
Or
(
req
.
Model
,
req
.
Name
))
name
:=
model
.
ParseName
(
cmp
.
Or
(
req
.
Model
,
req
.
Name
))
if
!
name
.
IsValid
()
{
if
!
name
.
IsValid
()
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"i
nvalid
m
odel
n
ame
"
})
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
errtypes
.
I
nvalid
M
odel
N
ame
ErrMsg
})
return
return
}
}
...
...
types/errtypes/errtypes.go
View file @
7ca71a6b
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
)
)
const
UnknownOllamaKeyErrMsg
=
"unknown ollama key"
const
UnknownOllamaKeyErrMsg
=
"unknown ollama key"
const
InvalidModelNameErrMsg
=
"invalid model name"
// TODO: This should have a structured response from the API
// TODO: This should have a structured response from the API
type
UnknownOllamaKey
struct
{
type
UnknownOllamaKey
struct
{
...
...
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