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
0f06a6da
Unverified
Commit
0f06a6da
authored
Dec 16, 2024
by
Jeffrey Morgan
Committed by
GitHub
Dec 16, 2024
Browse files
llm: loosen format check to default to no format (#8127)
parent
8f805dd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
llm/server.go
llm/server.go
+7
-13
No files found.
llm/server.go
View file @
0f06a6da
...
...
@@ -722,20 +722,14 @@ func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn fu
return
fmt
.
Errorf
(
"unexpected server status: %s"
,
status
.
ToString
())
}
if
len
(
req
.
Format
)
>
0
{
switch
{
case
bytes
.
Equal
(
req
.
Format
,
[]
byte
(
`"json"`
))
:
request
[
"grammar"
]
=
grammarJSON
case
bytes
.
HasPrefix
(
req
.
Format
,
[]
byte
(
"{"
))
:
// User provided a JSON schema
g
:=
llama
.
SchemaToGrammar
(
req
.
Format
)
if
g
==
nil
{
return
fmt
.
Errorf
(
"invalid JSON schema in format"
)
}
request
[
"grammar"
]
=
string
(
g
)
default
:
return
errors
.
New
(
`invalid format: expected "json" or a JSON schema`
)
if
bytes
.
Equal
(
req
.
Format
,
[]
byte
(
`"json"`
))
{
request
[
"grammar"
]
=
grammarJSON
}
else
if
bytes
.
HasPrefix
(
req
.
Format
,
[]
byte
(
"{"
))
{
g
:=
llama
.
SchemaToGrammar
(
req
.
Format
)
if
g
==
nil
{
return
fmt
.
Errorf
(
"invalid JSON schema in format"
)
}
request
[
"grammar"
]
=
string
(
g
)
}
// Handling JSON marshaling with special characters unescaped.
...
...
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