Skip to content

Base prompt model driver

BasePromptModelDriver

Bases: SerializableMixin, ABC

Source code in griptape/drivers/prompt_model/base_prompt_model_driver.py
@define
class BasePromptModelDriver(SerializableMixin, ABC):
    max_tokens: Optional[int] = field(default=None, kw_only=True)
    prompt_driver: Optional[BasePromptDriver] = field(default=None, kw_only=True)
    supports_streaming: bool = field(default=True, kw_only=True)

    @property
    @abstractmethod
    def tokenizer(self) -> BaseTokenizer: ...

    @abstractmethod
    def prompt_stack_to_model_input(self, prompt_stack: PromptStack) -> str | list | dict: ...

    @abstractmethod
    def prompt_stack_to_model_params(self, prompt_stack: PromptStack) -> dict: ...

    @abstractmethod
    def process_output(self, output: list[dict] | str | bytes) -> TextArtifact: ...

max_tokens: Optional[int] = field(default=None, kw_only=True) class-attribute instance-attribute

prompt_driver: Optional[BasePromptDriver] = field(default=None, kw_only=True) class-attribute instance-attribute

supports_streaming: bool = field(default=True, kw_only=True) class-attribute instance-attribute

tokenizer: BaseTokenizer abstractmethod property

process_output(output) abstractmethod

Source code in griptape/drivers/prompt_model/base_prompt_model_driver.py
@abstractmethod
def process_output(self, output: list[dict] | str | bytes) -> TextArtifact: ...

prompt_stack_to_model_input(prompt_stack) abstractmethod

Source code in griptape/drivers/prompt_model/base_prompt_model_driver.py
@abstractmethod
def prompt_stack_to_model_input(self, prompt_stack: PromptStack) -> str | list | dict: ...

prompt_stack_to_model_params(prompt_stack) abstractmethod

Source code in griptape/drivers/prompt_model/base_prompt_model_driver.py
@abstractmethod
def prompt_stack_to_model_params(self, prompt_stack: PromptStack) -> dict: ...