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
3c2c5869
"vscode:/vscode.git/clone" did not exist on "0974b4c6067165434fa715654b355b41beb5fceb"
Unverified
Commit
3c2c5869
authored
Feb 23, 2024
by
Cody Yu
Committed by
GitHub
Feb 24, 2024
Browse files
Support outlines > 0.0.31 (#219)
parent
4cb9aaed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
python/pyproject.toml
python/pyproject.toml
+1
-1
python/sglang/srt/constrained/__init__.py
python/sglang/srt/constrained/__init__.py
+23
-1
No files found.
python/pyproject.toml
View file @
3c2c5869
...
...
@@ -20,7 +20,7 @@ dependencies = [
[project.optional-dependencies]
srt
=
[
"aiohttp"
,
"fastapi"
,
"psutil"
,
"rpyc"
,
"torch"
,
"uvloop"
,
"uvicorn"
,
"zmq"
,
"vllm>=0.2.5"
,
"interegular"
,
"lark"
,
"numba"
,
"pydantic"
,
"referencing"
,
"diskcache"
,
"cloudpickle"
,
"pillow"
,
"outlines>=0.0.27
,<=0.0.30
"
]
"pydantic"
,
"referencing"
,
"diskcache"
,
"cloudpickle"
,
"pillow"
,
"outlines>=0.0.27"
]
openai
=
[
"openai>=1.0"
,
"numpy"
]
anthropic
=
[
"anthropic"
,
"numpy"
]
all
=
["sglang[srt]
", "
sglang
[openai]
", "
sglang
[anthropic]"]
...
...
python/sglang/srt/constrained/__init__.py
View file @
3c2c5869
import
json
from
typing
import
Dict
,
Optional
,
Union
from
outlines.caching
import
cache
as
disk_cache
from
outlines.caching
import
disable_cache
from
outlines.fsm.fsm
import
RegexFSM
from
outlines.fsm.json_schema
import
build_regex_from_object
from
outlines.fsm.regex
import
FSMInfo
,
make_deterministic_fsm
from
outlines.models.transformers
import
TransformerTokenizer
from
pydantic
import
BaseModel
try
:
from
outlines.fsm.json_schema
import
build_regex_from_object
except
ImportError
:
# Since outlines 0.0.32, build_regex_from_object is replaced by build_regex_from_schema,
# which only accepts string schema as input.
from
outlines.fsm.json_schema
import
build_regex_from_schema
def
build_regex_from_object
(
object
:
Union
[
str
,
BaseModel
,
Dict
],
whitespace_pattern
:
Optional
[
str
]
=
None
):
if
isinstance
(
object
,
type
(
BaseModel
)):
schema
=
json
.
dumps
(
object
.
model_json_schema
())
elif
isinstance
(
object
,
Dict
):
schema
=
json
.
dumps
(
object
)
else
:
schema
=
object
return
build_regex_from_schema
(
schema
,
whitespace_pattern
)
__all__
=
[
"RegexFSM"
,
...
...
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