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
3ca56b5a
Commit
3ca56b5a
authored
Nov 14, 2023
by
Michael Yang
Browse files
add create modelfile field
parent
b0d14ed5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
api/types.go
api/types.go
+4
-3
server/routes.go
server/routes.go
+16
-6
No files found.
api/types.go
View file @
3ca56b5a
...
@@ -99,9 +99,10 @@ type EmbeddingResponse struct {
...
@@ -99,9 +99,10 @@ type EmbeddingResponse struct {
}
}
type
CreateRequest
struct
{
type
CreateRequest
struct
{
Name
string
`json:"name"`
Name
string
`json:"name"`
Path
string
`json:"path"`
Path
string
`json:"path"`
Stream
*
bool
`json:"stream,omitempty"`
Modelfile
string
`json:"modelfile"`
Stream
*
bool
`json:"stream,omitempty"`
}
}
type
DeleteRequest
struct
{
type
DeleteRequest
struct
{
...
...
server/routes.go
View file @
3ca56b5a
...
@@ -410,17 +410,27 @@ func CreateModelHandler(c *gin.Context) {
...
@@ -410,17 +410,27 @@ func CreateModelHandler(c *gin.Context) {
return
return
}
}
if
req
.
Name
==
""
||
req
.
Path
==
""
{
if
req
.
Name
==
""
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name
and path are
required"
})
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"name
is
required"
})
return
return
}
}
modelfile
,
err
:=
os
.
Open
(
req
.
Path
)
if
req
.
Path
==
""
&&
req
.
Modelfile
==
""
{
if
err
!=
nil
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
"path or modelfile are required"
})
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
defer
modelfile
.
Close
()
var
modelfile
io
.
Reader
=
strings
.
NewReader
(
req
.
Modelfile
)
if
req
.
Path
!=
""
&&
req
.
Modelfile
==
""
{
bin
,
err
:=
os
.
Open
(
req
.
Path
)
if
err
!=
nil
{
c
.
AbortWithStatusJSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"error"
:
fmt
.
Sprintf
(
"error reading modelfile: %s"
,
err
)})
return
}
defer
bin
.
Close
()
modelfile
=
bin
}
commands
,
err
:=
parser
.
Parse
(
modelfile
)
commands
,
err
:=
parser
.
Parse
(
modelfile
)
if
err
!=
nil
{
if
err
!=
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