import outlines (#168)

This commit is contained in:
Liangsheng Yin
2024-02-09 10:13:02 +08:00
committed by GitHub
parent cba5027332
commit 37b42297f8
12 changed files with 27 additions and 1464 deletions

View File

@@ -5,10 +5,9 @@ python json_decode.py
"""
from enum import Enum
from pydantic import BaseModel, constr
import sglang as sgl
from sglang.srt.constrained.json_schema import build_regex_from_object
from pydantic import BaseModel
from sglang.srt.constrained import build_regex_from_object
character_regex = (
r"""\{\n"""
@@ -30,7 +29,10 @@ character_regex = (
@sgl.function
def character_gen(s, name):
s += name + " is a character in Harry Potter. Please fill in the following information about this character.\n"
s += (
name
+ " is a character in Harry Potter. Please fill in the following information about this character.\n"
)
s += sgl.gen("json_output", max_tokens=256, regex=character_regex)
@@ -65,11 +67,6 @@ def pydantic_wizard_gen(s):
)
def driver_character_gen():
state = character_gen.run(name="Hermione Granger")
print(state.text())
def driver_pydantic_wizard_gen():
state = pydantic_wizard_gen.run()
print(state.text())