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
74b3bfaa
Commit
74b3bfaa
authored
Jan 30, 2024
by
Lianmin Zheng
Browse files
format code
parent
4a634cf6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
10 deletions
+16
-10
python/sglang/srt/managers/openai_protocol.py
python/sglang/srt/managers/openai_protocol.py
+1
-1
python/sglang/srt/server.py
python/sglang/srt/server.py
+1
-3
python/sglang/srt/utils.py
python/sglang/srt/utils.py
+12
-4
python/sglang/test/test_conversation.py
python/sglang/test/test_conversation.py
+1
-1
python/sglang/test/test_openai_protocol.py
python/sglang/test/test_openai_protocol.py
+1
-1
No files found.
python/sglang/srt/managers/openai_protocol.py
View file @
74b3bfaa
import
time
import
time
from
typing
import
Dict
,
List
,
Optional
,
Union
from
typing
import
Dict
,
List
,
Optional
,
Union
from
typing_extensions
import
Literal
from
pydantic
import
BaseModel
,
Field
from
pydantic
import
BaseModel
,
Field
from
typing_extensions
import
Literal
class
LogProbs
(
BaseModel
):
class
LogProbs
(
BaseModel
):
...
...
python/sglang/srt/server.py
View file @
74b3bfaa
...
@@ -440,9 +440,7 @@ class Runtime:
...
@@ -440,9 +440,7 @@ class Runtime:
additional_ports
:
Optional
[
Union
[
List
[
int
],
int
]]
=
None
,
additional_ports
:
Optional
[
Union
[
List
[
int
],
int
]]
=
None
,
):
):
host
=
"127.0.0.1"
host
=
"127.0.0.1"
port
,
additional_ports
=
handle_port_init
(
port
,
additional_ports
=
handle_port_init
(
port
,
additional_ports
,
tp_size
)
port
,
additional_ports
,
tp_size
)
self
.
server_args
=
ServerArgs
(
self
.
server_args
=
ServerArgs
(
model_path
=
model_path
,
model_path
=
model_path
,
tokenizer_path
=
tokenizer_path
,
tokenizer_path
=
tokenizer_path
,
...
...
python/sglang/srt/utils.py
View file @
74b3bfaa
...
@@ -6,6 +6,7 @@ import sys
...
@@ -6,6 +6,7 @@ import sys
import
time
import
time
import
traceback
import
traceback
from
io
import
BytesIO
from
io
import
BytesIO
from
typing
import
List
,
Optional
import
numpy
as
np
import
numpy
as
np
import
requests
import
requests
...
@@ -108,10 +109,16 @@ def check_port(port):
...
@@ -108,10 +109,16 @@ def check_port(port):
return
False
return
False
def
handle_port_init
(
port
:
Optional
[
int
]
=
None
,
additional_ports
:
Optional
[
List
[
int
]]
=
None
,
tp_size
:
int
=
1
):
def
handle_port_init
(
port
:
Optional
[
int
]
=
None
,
additional_ports
:
Optional
[
List
[
int
]]
=
None
,
tp_size
:
int
=
1
,
):
port
=
30000
if
port
is
None
else
port
port
=
30000
if
port
is
None
else
port
additional_ports
=
[]
if
additional_ports
is
None
else
additional_ports
additional_ports
=
[]
if
additional_ports
is
None
else
additional_ports
additional_ports
=
[
additional_ports
]
if
isinstance
(
additional_ports
,
int
)
else
additional_ports
additional_ports
=
(
[
additional_ports
]
if
isinstance
(
additional_ports
,
int
)
else
additional_ports
)
# first check on server port
# first check on server port
if
not
check_port
(
port
):
if
not
check_port
(
port
):
new_port
=
alloc_usable_network_port
(
1
,
used_list
=
[
port
])[
0
]
new_port
=
alloc_usable_network_port
(
1
,
used_list
=
[
port
])[
0
]
...
@@ -130,9 +137,10 @@ def handle_port_init(port: Optional[int] = None, additional_ports: Optional[List
...
@@ -130,9 +137,10 @@ def handle_port_init(port: Optional[int] = None, additional_ports: Optional[List
)
)
can_use_ports
.
extend
(
addtional_can_use_ports
)
can_use_ports
.
extend
(
addtional_can_use_ports
)
additional_ports
=
can_use_ports
[:
4
+
tp_size
]
additional_ports
=
can_use_ports
[:
4
+
tp_size
]
return
port
,
additional_ports
return
port
,
additional_ports
def
get_exception_traceback
():
def
get_exception_traceback
():
etype
,
value
,
tb
=
sys
.
exc_info
()
etype
,
value
,
tb
=
sys
.
exc_info
()
err_str
=
""
.
join
(
traceback
.
format_exception
(
etype
,
value
,
tb
))
err_str
=
""
.
join
(
traceback
.
format_exception
(
etype
,
value
,
tb
))
...
...
python/sglang/test/test_conversation.py
View file @
74b3bfaa
from
sglang.srt.conversation
import
generate_chat_conv
from
sglang.srt.conversation
import
generate_chat_conv
from
sglang.srt.managers.openai_protocol
import
(
from
sglang.srt.managers.openai_protocol
import
(
ChatCompletionMessageGenericParam
,
ChatCompletionMessageContentImagePart
,
ChatCompletionMessageContentImagePart
,
ChatCompletionMessageContentImageURL
,
ChatCompletionMessageContentImageURL
,
ChatCompletionMessageContentTextPart
,
ChatCompletionMessageContentTextPart
,
ChatCompletionMessageGenericParam
,
ChatCompletionMessageUserParam
,
ChatCompletionMessageUserParam
,
ChatCompletionRequest
,
ChatCompletionRequest
,
)
)
...
...
python/sglang/test/test_openai_protocol.py
View file @
74b3bfaa
from
sglang.srt.managers.openai_protocol
import
(
from
sglang.srt.managers.openai_protocol
import
(
ChatCompletionMessageGenericParam
,
ChatCompletionMessageContentImagePart
,
ChatCompletionMessageContentImagePart
,
ChatCompletionMessageContentImageURL
,
ChatCompletionMessageContentImageURL
,
ChatCompletionMessageContentTextPart
,
ChatCompletionMessageContentTextPart
,
ChatCompletionMessageGenericParam
,
ChatCompletionMessageUserParam
,
ChatCompletionMessageUserParam
,
ChatCompletionRequest
,
ChatCompletionRequest
,
)
)
...
...
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