sgl-project / sglang

SGLang is a structured generation language designed for large language models (LLMs). It makes your interaction with models faster and more controllable.
Apache License 2.0
2.75k stars 177 forks source link

[Minor] Correct Optional type hints in api #526

Closed fpreiss closed 2 weeks ago

fpreiss commented 2 weeks ago

The given type annotations in python/sglang/api.py should probably be typed as Optional.

Bonus Question: Generally the code base uses type annotations in most situations (which I personally enjoy working with). When reading through the examples however I find it a little bit harder to understand what kind of objects are passed around. Is there an interest in having type annotations added to the example code? I know that its not everybody's preference.

Qubitium commented 2 weeks ago

@fpreiss Absolutely type hints should be everywhere even if python runtime ignores them. I would encourage adding accurate type-hints everywhere you see fit. I have been doing the same for sglang codes that I come across to refactor or change.