Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion python/sglang/srt/entrypoints/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,13 @@ def available_models():
served_model_names = [_global_state.tokenizer_manager.served_model_name]
model_cards = []
for served_model_name in served_model_names:
model_cards.append(ModelCard(id=served_model_name, root=served_model_name))
model_cards.append(
ModelCard(
id=served_model_name,
root=served_model_name,
max_model_len=_global_state.tokenizer_manager.model_config.context_len,
)
)
return ModelList(data=model_cards)


Expand Down
1 change: 1 addition & 0 deletions python/sglang/srt/openai_api/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ModelCard(BaseModel):
created: int = Field(default_factory=lambda: int(time.time()))
owned_by: str = "sglang"
root: Optional[str] = None
max_model_len: Optional[int] = None

This comment was marked as outdated.



class ModelList(BaseModel):
Expand Down
6 changes: 6 additions & 0 deletions test/srt/test_openai_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ def test_response_prefill(self):
.startswith('"name": "SmartHome Mini",')
)

def test_model_list(self):
client = openai.Client(api_key=self.api_key, base_url=self.base_url)
models = list(client.models.list())
assert len(models) == 1
assert isinstance(getattr(models[0], "max_model_len", None), int)


# -------------------------------------------------------------------------
# EBNF Test Class: TestOpenAIServerEBNF
Expand Down
Loading