-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aliases and deprecation warnings for old API
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .api import choice, continuation, format, json, regex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import warnings | ||
from typing import Callable, List, Optional, Union | ||
|
||
import outlines | ||
from outlines.generate.samplers import Sampler, multinomial | ||
|
||
|
||
def json( | ||
model, | ||
schema_object: Union[str, object, Callable], | ||
max_tokens: Optional[int] = None, | ||
sampler: Sampler = multinomial, | ||
): | ||
warnings.warn( | ||
"`outlines.text.generate.json` is deprecated, please use `outlines.generate.json` instead. " | ||
"The old import path will be removed in Outlines v0.0.15.", | ||
DeprecationWarning, | ||
) | ||
return outlines.generate.json(model, schema_object, max_tokens, sampler=sampler) | ||
|
||
|
||
def regex( | ||
model, | ||
regex_str: str, | ||
max_tokens: Optional[int] = None, | ||
sampler: Sampler = multinomial, | ||
): | ||
warnings.warn( | ||
"`outlines.text.generate.regex` is deprecated, please use `outlines.generate.regex` instead. " | ||
"The old import path will be removed in Outlines v0.0.15.", | ||
DeprecationWarning, | ||
) | ||
return outlines.generate.regex(model, regex_str, max_tokens, sampler=sampler) | ||
|
||
|
||
def format( | ||
model, python_type, max_tokens: Optional[int] = None, sampler: Sampler = multinomial | ||
): | ||
warnings.warn( | ||
"`outlines.text.generate.format` is deprecated, please use `outlines.generate.format` instead. " | ||
"The old import path will be removed in Outlines v0.0.15.", | ||
DeprecationWarning, | ||
) | ||
return outlines.generate.format(model, python_type, max_tokens, sampler=sampler) | ||
|
||
|
||
def continuation( | ||
model, max_tokens: Optional[int] = None, sampler: Sampler = multinomial | ||
): | ||
warnings.warn( | ||
"`outlines.text.generate.continuation` is deprecated, please use `outlines.generate.text` instead. " | ||
"The old import path will be removed in Outlines v0.0.15.", | ||
DeprecationWarning, | ||
) | ||
return outlines.generate.text(model, max_tokens, sampler=sampler) | ||
|
||
|
||
def choice( | ||
model, | ||
choices: List[str], | ||
max_tokens: Optional[int] = None, | ||
sampler: Sampler = multinomial, | ||
): | ||
warnings.warn( | ||
"`outlines.text.generate.choice` is deprecated, please use `outlines.generate.choice` instead. " | ||
"The old import path will be removed in Outlines v0.0.15.", | ||
DeprecationWarning, | ||
) | ||
return outlines.generate.choice(model, choices, max_tokens, sampler) |