You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most cases we want to do either of two things with the JSON generated by a model:
Parse it, typically with a Pydantic BaseModel;
Call a function with the values it contains.
In the second case the user would need to define a Pydantic model just for this purpose. We could make this easier by allowing users to pass a function to generate.json and generate the JSON Schema from the functions' signature.
importoutlines.textastextimportoutlines.modelsasmodelsdefdo_something(foo: str, bar: List[int]):
...
model=models.transformers("gpt2")
res=text.generate.json(model, do_something)(prompt)
do_something(**res)
The text was updated successfully, but these errors were encountered:
In most cases we want to do either of two things with the JSON generated by a model:
BaseModel
;In the second case the user would need to define a Pydantic model just for this purpose. We could make this easier by allowing users to pass a function to
generate.json
and generate the JSON Schema from the functions' signature.The text was updated successfully, but these errors were encountered: