Filling
Making natural language structured.
Schema
The supported types for model schemas are currently limited. Below are the supported types:
- General types:
int,float,str,bool - Container types:
list,dict - Model types: Any dataclass with supported types; Any Pydantic model with supported types
- Extras:
Union,Literal
As for adding comments:
- dataclasses: Use
Annotated[T, "Comments"]. - Pydantic models: Use
Field(description="Comments"). See Fields.
Under the hood
aism first checks if the __aism_prompt__ attribute is present in the class.
If not, aism tokenizes the model, parses the tokens, then adds the attribute itself.
The next time aism gets the attribute value and uses it.
A similar process of caching also applies to __aism_filler__, which is a function
used to quickly fill a model from a dictionary.
For larger-scale projects, it's recommended to let aism do the tokenizing work at startup time:
from aism import fillable
@fillable
@dataclass
class Person:
name: str
print(getattr(Person, "__aism_prompt__"))
print(getattr(Person, "__aism_filler__"))from aism import fillable
@fillable
class Person(BaseModel):
name: str
print(getattr(Person, "__aism_prompt__"))
print(getattr(Person, "__aism_filler__"))