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
906d795f
Unverified
Commit
906d795f
authored
Dec 01, 2024
by
gobraves
Committed by
GitHub
Dec 01, 2024
Browse files
Feat: upgrade outlines & support compatibility with the old version (#2292)
parent
118b6af3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
python/sglang/srt/constrained/outlines_backend.py
python/sglang/srt/constrained/outlines_backend.py
+6
-1
python/sglang/srt/constrained/outlines_jump_forward.py
python/sglang/srt/constrained/outlines_jump_forward.py
+8
-1
No files found.
python/sglang/srt/constrained/outlines_backend.py
View file @
906d795f
...
@@ -152,7 +152,12 @@ class OutlinesGrammarBackend(BaseGrammarBackend):
...
@@ -152,7 +152,12 @@ class OutlinesGrammarBackend(BaseGrammarBackend):
raise
ValueError
(
f
"Invalid key_type:
{
key_type
}
"
)
raise
ValueError
(
f
"Invalid key_type:
{
key_type
}
"
)
try
:
try
:
guide
=
RegexGuide
(
regex
,
self
.
outlines_tokenizer
)
if
hasattr
(
RegexGuide
,
"from_regex"
):
# outlines >= 0.1.1
guide
=
RegexGuide
.
from_regex
(
regex
,
self
.
outlines_tokenizer
)
else
:
# outlines <= 0.0.46
guide
=
RegexGuide
(
regex
,
self
.
outlines_tokenizer
)
except
interegular
.
patterns
.
InvalidSyntax
as
e
:
except
interegular
.
patterns
.
InvalidSyntax
as
e
:
logger
.
warning
(
f
"skip invalid regex schema:
{
regex
=
}
,
{
e
=
}
"
)
logger
.
warning
(
f
"skip invalid regex schema:
{
regex
=
}
,
{
e
=
}
"
)
return
None
return
None
...
...
python/sglang/srt/constrained/outlines_jump_forward.py
View file @
906d795f
...
@@ -23,7 +23,14 @@ from collections import defaultdict
...
@@ -23,7 +23,14 @@ from collections import defaultdict
import
interegular
import
interegular
from
interegular
import
InvalidSyntax
from
interegular
import
InvalidSyntax
from
outlines.caching
import
cache
as
disk_cache
from
outlines.caching
import
cache
as
disk_cache
from
outlines.fsm.regex
import
FSMInfo
,
make_byte_level_fsm
,
make_deterministic_fsm
try
:
# outlines >= 0.1.0
from
outlines_core.fsm.outlines_core_rs
import
FSMInfo
from
outlines_core.fsm.regex
import
make_byte_level_fsm
,
make_deterministic_fsm
except
ImportError
:
# outlines <= 0.0.46
from
outlines.fsm.regex
import
FSMInfo
,
make_byte_level_fsm
,
make_deterministic_fsm
IP_REGEX
=
r
"((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)"
IP_REGEX
=
r
"((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)"
...
...
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