Bases: DispatcherSpanMixin
, ABC
, Generic[Model]
A base class for LLM-powered function that return a pydantic model.
Note: this interface is not yet stable.
Source code in llama-index-core/llama_index/core/types.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 | class BasePydanticProgram(DispatcherSpanMixin, ABC, Generic[Model]):
"""A base class for LLM-powered function that return a pydantic model.
Note: this interface is not yet stable.
"""
@property
@abstractmethod
def output_cls(self) -> Type[Model]:
pass
@abstractmethod
def __call__(self, *args: Any, **kwds: Any) -> Model:
pass
async def acall(self, *args: Any, **kwds: Any) -> Model:
return self(*args, **kwds)
def stream_call(self, *args: Any, **kwds: Any) -> Generator[Model, None, None]:
raise NotImplementedError("stream_call is not supported by default.")
async def astream_call(
self, *args: Any, **kwds: Any
) -> AsyncGenerator[Model, None]:
raise NotImplementedError("astream_call is not supported by default.")
|