Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
138485a8
Unverified
Commit
138485a8
authored
Apr 19, 2024
by
Ayush Rautwar
Committed by
GitHub
Apr 19, 2024
Browse files
[Bugfix] Add fix for JSON whitespace (#4189)
Co-authored-by:
Ubuntu
<
ubuntu@ip-172-31-13-147.ec2.internal
>
parent
bc9df157
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
tests/entrypoints/test_openai_server.py
tests/entrypoints/test_openai_server.py
+14
-13
vllm/model_executor/guided_decoding/outlines_logits_processors.py
...el_executor/guided_decoding/outlines_logits_processors.py
+5
-0
No files found.
tests/entrypoints/test_openai_server.py
View file @
138485a8
...
@@ -754,19 +754,20 @@ async def test_guided_choice_chat_logprobs(server, client: openai.AsyncOpenAI,
...
@@ -754,19 +754,20 @@ async def test_guided_choice_chat_logprobs(server, client: openai.AsyncOpenAI,
async
def
test_response_format_json_object
(
server
,
client
:
openai
.
AsyncOpenAI
):
async
def
test_response_format_json_object
(
server
,
client
:
openai
.
AsyncOpenAI
):
resp
=
await
client
.
chat
.
completions
.
create
(
for
_
in
range
(
2
):
model
=
MODEL_NAME
,
resp
=
await
client
.
chat
.
completions
.
create
(
messages
=
[{
model
=
MODEL_NAME
,
"role"
:
messages
=
[{
"user"
,
"role"
:
"content"
:
(
'what is 1+1? please respond with a JSON object, '
"user"
,
'the format is {"result": 2}'
)
"content"
:
(
'what is 1+1? please respond with a JSON object, '
}],
'the format is {"result": 2}'
)
response_format
=
{
"type"
:
"json_object"
})
}],
response_format
=
{
"type"
:
"json_object"
})
content
=
resp
.
choices
[
0
].
message
.
content
loaded
=
json
.
loads
(
content
)
content
=
resp
.
choices
[
0
].
message
.
content
assert
loaded
==
{
"result"
:
2
},
loaded
loaded
=
json
.
loads
(
content
)
assert
loaded
==
{
"result"
:
2
},
loaded
async
def
test_guided_grammar
(
server
,
client
:
openai
.
AsyncOpenAI
):
async
def
test_guided_grammar
(
server
,
client
:
openai
.
AsyncOpenAI
):
...
...
vllm/model_executor/guided_decoding/outlines_logits_processors.py
View file @
138485a8
...
@@ -131,6 +131,11 @@ class CFGLogitsProcessor(BaseLogitsProcessor):
...
@@ -131,6 +131,11 @@ class CFGLogitsProcessor(BaseLogitsProcessor):
fsm
=
CFGFSM
(
cfg
,
tokenizer
)
fsm
=
CFGFSM
(
cfg
,
tokenizer
)
self
.
fsm
=
fsm
self
.
fsm
=
fsm
def
init_state
(
self
):
"""Initialize state with a CFGFSM copy."""
super
().
init_state
()
self
.
fsm
=
self
.
fsm
.
copy
()
@
lru_cache
@
lru_cache
def
_adapt_tokenizer
(
tokenizer
:
PreTrainedTokenizerBase
):
def
_adapt_tokenizer
(
tokenizer
:
PreTrainedTokenizerBase
):
...
...
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