diff --git a/test/examples/ai_powered_decorator/gen_user_info.py b/test/examples/ai_powered_decorator/gen_user_info.py index fa8943e..eacd7ca 100644 --- a/test/examples/ai_powered_decorator/gen_user_info.py +++ b/test/examples/ai_powered_decorator/gen_user_info.py @@ -10,6 +10,7 @@ class UserInfo: @ai_powered def gen_user_info() -> UserInfo: + ''' ramdomly generate user info for testing, None is used for unknown fields ''' ... @ai_powered diff --git a/test/json_schema/annotated.py b/test/json_schema/annotated.py new file mode 100644 index 0000000..963e3cc --- /dev/null +++ b/test/json_schema/annotated.py @@ -0,0 +1,18 @@ +import json +import msgspec +from typing_extensions import Annotated +from pydantic.dataclasses import dataclass +from typing import Optional + +from ai_powered.schema_deref import deref + +@dataclass +class UserInfo: + name: str + country: Annotated[Optional[str], "None is used for unknown cases"] + age: Annotated[Optional[str], "None is used for unknown cases"] + +if __name__ == "__main__": + schema = msgspec.json.schema(UserInfo) + print("schema =", json.dumps(schema, indent=2)) + print("deref(schema) =", json.dumps(deref(schema), indent=2))