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
de52b6c2
Unverified
Commit
de52b6c2
authored
Dec 06, 2024
by
Parth Sareen
Committed by
GitHub
Dec 06, 2024
Browse files
bugfix: "null" value json mode (#7979)
parent
acd7d032
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
cmd/cmd.go
cmd/cmd.go
+8
-0
llm/server.go
llm/server.go
+1
-1
No files found.
cmd/cmd.go
View file @
de52b6c2
...
@@ -1036,6 +1036,10 @@ func chat(cmd *cobra.Command, opts runOptions) (*api.Message, error) {
...
@@ -1036,6 +1036,10 @@ func chat(cmd *cobra.Command, opts runOptions) (*api.Message, error) {
return
nil
return
nil
}
}
if
opts
.
Format
==
"json"
{
opts
.
Format
=
`"`
+
opts
.
Format
+
`"`
}
req
:=
&
api
.
ChatRequest
{
req
:=
&
api
.
ChatRequest
{
Model
:
opts
.
Model
,
Model
:
opts
.
Model
,
Messages
:
opts
.
Messages
,
Messages
:
opts
.
Messages
,
...
@@ -1121,6 +1125,10 @@ func generate(cmd *cobra.Command, opts runOptions) error {
...
@@ -1121,6 +1125,10 @@ func generate(cmd *cobra.Command, opts runOptions) error {
}
}
}
}
if
opts
.
Format
==
"json"
{
opts
.
Format
=
`"`
+
opts
.
Format
+
`"`
}
request
:=
api
.
GenerateRequest
{
request
:=
api
.
GenerateRequest
{
Model
:
opts
.
Model
,
Model
:
opts
.
Model
,
Prompt
:
opts
.
Prompt
,
Prompt
:
opts
.
Prompt
,
...
...
llm/server.go
View file @
de52b6c2
...
@@ -746,7 +746,7 @@ func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn fu
...
@@ -746,7 +746,7 @@ func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn fu
// TODO (parthsareen): Move conversion to grammar with sampling logic
// TODO (parthsareen): Move conversion to grammar with sampling logic
// API should do error handling for invalid formats
// API should do error handling for invalid formats
if
req
.
Format
!=
nil
{
if
req
.
Format
!=
nil
&&
strings
.
TrimSpace
(
string
(
req
.
Format
))
!=
"null"
{
if
strings
.
ToLower
(
strings
.
TrimSpace
(
string
(
req
.
Format
)))
==
`"json"`
{
if
strings
.
ToLower
(
strings
.
TrimSpace
(
string
(
req
.
Format
)))
==
`"json"`
{
request
[
"grammar"
]
=
jsonGrammar
request
[
"grammar"
]
=
jsonGrammar
if
!
strings
.
Contains
(
strings
.
ToLower
(
req
.
Prompt
),
"json"
)
{
if
!
strings
.
Contains
(
strings
.
ToLower
(
req
.
Prompt
),
"json"
)
{
...
...
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