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
2130c070
Unverified
Commit
2130c070
authored
Oct 05, 2023
by
Bruce MacDonald
Committed by
GitHub
Oct 05, 2023
Browse files
output type parsed from modelfile (#678)
parent
61ff1946
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
api/types.go
api/types.go
+6
-6
server/images.go
server/images.go
+1
-1
No files found.
api/types.go
View file @
2130c070
...
@@ -227,12 +227,12 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
...
@@ -227,12 +227,12 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
// when JSON unmarshals numbers, it uses float64, not int
// when JSON unmarshals numbers, it uses float64, not int
field
.
SetInt
(
int64
(
t
))
field
.
SetInt
(
int64
(
t
))
default
:
default
:
log
.
Printf
(
"could not convert model parameter %v to int, skipped"
,
key
)
log
.
Printf
(
"could not convert model parameter %v
of type %T
to int, skipped"
,
key
,
val
)
}
}
case
reflect
.
Bool
:
case
reflect
.
Bool
:
val
,
ok
:=
val
.
(
bool
)
val
,
ok
:=
val
.
(
bool
)
if
!
ok
{
if
!
ok
{
log
.
Printf
(
"could not convert model parameter %v to bool, skipped"
,
key
)
log
.
Printf
(
"could not convert model parameter %v
of type %T
to bool, skipped"
,
key
,
val
)
continue
continue
}
}
field
.
SetBool
(
val
)
field
.
SetBool
(
val
)
...
@@ -240,14 +240,14 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
...
@@ -240,14 +240,14 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
// JSON unmarshals to float64
// JSON unmarshals to float64
val
,
ok
:=
val
.
(
float64
)
val
,
ok
:=
val
.
(
float64
)
if
!
ok
{
if
!
ok
{
log
.
Printf
(
"could not convert model parameter %v to float32, skipped"
,
key
)
log
.
Printf
(
"could not convert model parameter %v
of type %T
to float32, skipped"
,
key
,
val
)
continue
continue
}
}
field
.
SetFloat
(
val
)
field
.
SetFloat
(
val
)
case
reflect
.
String
:
case
reflect
.
String
:
val
,
ok
:=
val
.
(
string
)
val
,
ok
:=
val
.
(
string
)
if
!
ok
{
if
!
ok
{
log
.
Printf
(
"could not convert model parameter %v to string, skipped"
,
key
)
log
.
Printf
(
"could not convert model parameter %v
of type %T
to string, skipped"
,
key
,
val
)
continue
continue
}
}
field
.
SetString
(
val
)
field
.
SetString
(
val
)
...
@@ -255,7 +255,7 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
...
@@ -255,7 +255,7 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
// JSON unmarshals to []interface{}, not []string
// JSON unmarshals to []interface{}, not []string
val
,
ok
:=
val
.
([]
interface
{})
val
,
ok
:=
val
.
([]
interface
{})
if
!
ok
{
if
!
ok
{
log
.
Printf
(
"could not convert model parameter %v to slice, skipped"
,
key
)
log
.
Printf
(
"could not convert model parameter %v
of type %T
to slice, skipped"
,
key
,
val
)
continue
continue
}
}
// convert []interface{} to []string
// convert []interface{} to []string
...
@@ -263,7 +263,7 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
...
@@ -263,7 +263,7 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
for
i
,
item
:=
range
val
{
for
i
,
item
:=
range
val
{
str
,
ok
:=
item
.
(
string
)
str
,
ok
:=
item
.
(
string
)
if
!
ok
{
if
!
ok
{
log
.
Printf
(
"could not convert model parameter %v to slice of strings, skipped"
,
key
)
log
.
Printf
(
"could not convert model parameter %v
of type %T
to slice of strings, skipped"
,
key
,
item
)
continue
continue
}
}
slice
[
i
]
=
str
slice
[
i
]
=
str
...
...
server/images.go
View file @
2130c070
...
@@ -831,7 +831,7 @@ func formatParams(params map[string][]string) (map[string]interface{}, error) {
...
@@ -831,7 +831,7 @@ func formatParams(params map[string][]string) (map[string]interface{}, error) {
return
nil
,
fmt
.
Errorf
(
"invalid int value %s"
,
vals
)
return
nil
,
fmt
.
Errorf
(
"invalid int value %s"
,
vals
)
}
}
out
[
key
]
=
int
(
intVal
)
out
[
key
]
=
intVal
case
reflect
.
Bool
:
case
reflect
.
Bool
:
boolVal
,
err
:=
strconv
.
ParseBool
(
vals
[
0
])
boolVal
,
err
:=
strconv
.
ParseBool
(
vals
[
0
])
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