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
689842b9
Commit
689842b9
authored
Oct 18, 2023
by
Michael Yang
Browse files
request: bad request when model missing fields
parent
a19d4764
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
server/routes.go
server/routes.go
+40
-0
No files found.
server/routes.go
View file @
689842b9
...
@@ -142,6 +142,11 @@ func GenerateHandler(c *gin.Context) {
...
@@ -142,6 +142,11 @@ func GenerateHandler(c *gin.Context) {
return
return
}
}
if
req
.
Model
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"model is required"
})
return
}
model
,
err
:=
GetModel
(
req
.
Model
)
model
,
err
:=
GetModel
(
req
.
Model
)
if
err
!=
nil
{
if
err
!=
nil
{
var
pErr
*
fs
.
PathError
var
pErr
*
fs
.
PathError
...
@@ -231,6 +236,11 @@ func EmbeddingHandler(c *gin.Context) {
...
@@ -231,6 +236,11 @@ func EmbeddingHandler(c *gin.Context) {
return
return
}
}
if
req
.
Model
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"model is required"
})
return
}
model
,
err
:=
GetModel
(
req
.
Model
)
model
,
err
:=
GetModel
(
req
.
Model
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
err
.
Error
()})
...
@@ -268,6 +278,11 @@ func PullModelHandler(c *gin.Context) {
...
@@ -268,6 +278,11 @@ func PullModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Name
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name is required"
})
return
}
ch
:=
make
(
chan
any
)
ch
:=
make
(
chan
any
)
go
func
()
{
go
func
()
{
defer
close
(
ch
)
defer
close
(
ch
)
...
@@ -302,6 +317,11 @@ func PushModelHandler(c *gin.Context) {
...
@@ -302,6 +317,11 @@ func PushModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Name
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name is required"
})
return
}
ch
:=
make
(
chan
any
)
ch
:=
make
(
chan
any
)
go
func
()
{
go
func
()
{
defer
close
(
ch
)
defer
close
(
ch
)
...
@@ -334,6 +354,11 @@ func CreateModelHandler(c *gin.Context) {
...
@@ -334,6 +354,11 @@ func CreateModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Name
==
""
||
req
.
Path
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name and path are required"
})
return
}
ch
:=
make
(
chan
any
)
ch
:=
make
(
chan
any
)
go
func
()
{
go
func
()
{
defer
close
(
ch
)
defer
close
(
ch
)
...
@@ -364,6 +389,11 @@ func DeleteModelHandler(c *gin.Context) {
...
@@ -364,6 +389,11 @@ func DeleteModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Name
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name is required"
})
return
}
if
err
:=
DeleteModel
(
req
.
Name
);
err
!=
nil
{
if
err
:=
DeleteModel
(
req
.
Name
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
c
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"error"
:
fmt
.
Sprintf
(
"model '%s' not found"
,
req
.
Name
)})
c
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"error"
:
fmt
.
Sprintf
(
"model '%s' not found"
,
req
.
Name
)})
...
@@ -394,6 +424,11 @@ func ShowModelHandler(c *gin.Context) {
...
@@ -394,6 +424,11 @@ func ShowModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Name
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name is required"
})
return
}
resp
,
err
:=
GetModelInfo
(
req
.
Name
)
resp
,
err
:=
GetModelInfo
(
req
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
...
@@ -505,6 +540,11 @@ func CopyModelHandler(c *gin.Context) {
...
@@ -505,6 +540,11 @@ func CopyModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Source
==
""
||
req
.
Destination
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"source add destination are required"
})
return
}
if
err
:=
CopyModel
(
req
.
Source
,
req
.
Destination
);
err
!=
nil
{
if
err
:=
CopyModel
(
req
.
Source
,
req
.
Destination
);
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
c
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"error"
:
fmt
.
Sprintf
(
"model '%s' not found"
,
req
.
Source
)})
c
.
JSON
(
http
.
StatusNotFound
,
gin
.
H
{
"error"
:
fmt
.
Sprintf
(
"model '%s' not found"
,
req
.
Source
)})
...
...
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