Base prompt driver
BasePromptDriver
Bases: SerializableMixin, ExponentialBackoffMixin, ABC
Base class for Prompt Drivers.
Attributes:
| Name | Type | Description |
|---|---|---|
temperature |
float
|
The temperature to use for the completion. |
max_tokens |
Optional[int]
|
The maximum number of tokens to generate. If not specified, the value will be automatically generated based by the tokenizer. |
structure |
Optional[Structure]
|
An optional |
prompt_stack_to_string |
str
|
A function that converts a |
ignored_exception_types |
tuple[type[Exception], ...]
|
A tuple of exception types to ignore. |
model |
str
|
The model name. |
tokenizer |
BaseTokenizer
|
An instance of |
stream |
bool
|
Whether to stream the completion or not. |
Source code in griptape/drivers/prompt/base_prompt_driver.py
ignored_exception_types: tuple[type[Exception], ...] = field(default=Factory(lambda: (ImportError, ValueError)), kw_only=True)
class-attribute
instance-attribute
max_tokens: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model: str = field(metadata={'serializable': True})
class-attribute
instance-attribute
stream: bool = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
structure: Optional[Structure] = field(default=None, kw_only=True)
class-attribute
instance-attribute
temperature: float = field(default=0.1, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: BaseTokenizer
instance-attribute
after_run(result)
before_run(prompt_stack)
Source code in griptape/drivers/prompt/base_prompt_driver.py
prompt_stack_to_string(prompt_stack)
Converts a Prompt Stack to a string for token counting or model input. This base implementation is only a rough approximation, and should be overridden by subclasses with model-specific tokens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_stack |
PromptStack
|
The Prompt Stack to convert to a string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A single string representation of the Prompt Stack. |