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
change
sglang
Commits
616b59f3
Unverified
Commit
616b59f3
authored
Aug 14, 2024
by
rainred
Committed by
GitHub
Aug 14, 2024
Browse files
[Feature] modify Runtime to support skip_tokenizer_init (#1088)
Co-authored-by:
lzhang
<
zhanglei@modelbest.cn
>
parent
c8423ca3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
python/sglang/srt/server.py
python/sglang/srt/server.py
+19
-9
No files found.
python/sglang/srt/server.py
View file @
616b59f3
...
...
@@ -533,11 +533,18 @@ class Runtime:
prompt
:
str
,
sampling_params
:
Optional
[
Dict
]
=
None
,
):
json_data
=
{
"text"
:
prompt
,
"sampling_params"
:
sampling_params
,
"stream"
:
True
,
}
if
self
.
server_args
.
skip_tokenizer_init
:
json_data
=
{
"input_ids"
:
prompt
,
"sampling_params"
:
sampling_params
,
"stream"
:
True
,
}
else
:
json_data
=
{
"text"
:
prompt
,
"sampling_params"
:
sampling_params
,
"stream"
:
True
,
}
pos
=
0
timeout
=
aiohttp
.
ClientTimeout
(
total
=
3
*
3600
)
...
...
@@ -549,10 +556,13 @@ class Runtime:
if
chunk
==
"data: [DONE]
\n\n
"
:
break
data
=
json
.
loads
(
chunk
[
5
:].
strip
(
"
\n
"
))
cur
=
data
[
"text"
][
pos
:]
if
cur
:
yield
cur
pos
+=
len
(
cur
)
if
hasattr
(
data
,
"text"
):
cur
=
data
[
"text"
][
pos
:]
if
cur
:
yield
cur
pos
+=
len
(
cur
)
else
:
yield
data
add_request
=
async_generate
...
...
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