Drivers
__all__ = ['BasePromptDriver', 'OpenAiChatPromptDriver', 'OpenAiCompletionPromptDriver', 'AzureOpenAiChatPromptDriver', 'AzureOpenAiCompletionPromptDriver', 'CoherePromptDriver', 'HuggingFacePipelinePromptDriver', 'HuggingFaceHubPromptDriver', 'AnthropicPromptDriver', 'AmazonSageMakerPromptDriver', 'AmazonBedrockPromptDriver', 'GooglePromptDriver', 'BaseMultiModelPromptDriver', 'DummyPromptDriver', 'BaseConversationMemoryDriver', 'LocalConversationMemoryDriver', 'AmazonDynamoDbConversationMemoryDriver', 'BaseEmbeddingDriver', 'OpenAiEmbeddingDriver', 'AzureOpenAiEmbeddingDriver', 'BaseMultiModelEmbeddingDriver', 'AmazonSageMakerEmbeddingDriver', 'AmazonBedrockTitanEmbeddingDriver', 'AmazonBedrockCohereEmbeddingDriver', 'VoyageAiEmbeddingDriver', 'HuggingFaceHubEmbeddingDriver', 'GoogleEmbeddingDriver', 'DummyEmbeddingDriver', 'BaseEmbeddingModelDriver', 'SageMakerHuggingFaceEmbeddingModelDriver', 'SageMakerTensorFlowHubEmbeddingModelDriver', 'BaseVectorStoreDriver', 'LocalVectorStoreDriver', 'PineconeVectorStoreDriver', 'MarqoVectorStoreDriver', 'MongoDbAtlasVectorStoreDriver', 'AzureMongoDbVectorStoreDriver', 'RedisVectorStoreDriver', 'OpenSearchVectorStoreDriver', 'AmazonOpenSearchVectorStoreDriver', 'PgVectorVectorStoreDriver', 'DummyVectorStoreDriver', 'BaseSqlDriver', 'AmazonRedshiftSqlDriver', 'SnowflakeSqlDriver', 'SqlDriver', 'BasePromptModelDriver', 'SageMakerLlamaPromptModelDriver', 'SageMakerFalconPromptModelDriver', 'BedrockTitanPromptModelDriver', 'BedrockClaudePromptModelDriver', 'BedrockJurassicPromptModelDriver', 'BedrockLlamaPromptModelDriver', 'BaseImageGenerationModelDriver', 'BedrockStableDiffusionImageGenerationModelDriver', 'BedrockTitanImageGenerationModelDriver', 'BaseImageGenerationDriver', 'BaseMultiModelImageGenerationDriver', 'OpenAiImageGenerationDriver', 'LeonardoImageGenerationDriver', 'AmazonBedrockImageGenerationDriver', 'AzureOpenAiImageGenerationDriver', 'DummyImageGenerationDriver', 'BaseImageQueryModelDriver', 'BedrockClaudeImageQueryModelDriver', 'BaseImageQueryDriver', 'OpenAiVisionImageQueryDriver', 'DummyImageQueryDriver', 'AnthropicImageQueryDriver', 'BaseMultiModelImageQueryDriver', 'AmazonBedrockImageQueryDriver', 'BaseWebScraperDriver', 'TrafilaturaWebScraperDriver', 'MarkdownifyWebScraperDriver', 'BaseEventListenerDriver', 'AmazonSqsEventListenerDriver', 'WebhookEventListenerDriver', 'AwsIotCoreEventListenerDriver', 'GriptapeCloudEventListenerDriver', 'BaseFileManagerDriver', 'LocalFileManagerDriver', 'AmazonS3FileManagerDriver', 'BaseStructureRunDriver', 'GriptapeCloudStructureRunDriver', 'LocalStructureRunDriver']
module-attribute
AmazonBedrockCohereEmbeddingDriver
Bases: BaseEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
Embedding model name. Defaults to DEFAULT_MODEL. |
input_type |
str
|
Defaults to |
session |
Session
|
Optionally provide custom |
tokenizer |
BedrockCohereTokenizer
|
Optionally provide custom |
bedrock_client |
Any
|
Optionally provide custom |
Source code in griptape/drivers/embedding/amazon_bedrock_cohere_embedding_driver.py
DEFAULT_MODEL = 'cohere.embed-english-v3'
class-attribute
instance-attribute
bedrock_client: Any = field(default=Factory(lambda self: self.session.client('bedrock-runtime'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
input_type: str = field(default='search_query', kw_only=True)
class-attribute
instance-attribute
model: str = field(default=DEFAULT_MODEL, kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
tokenizer: BedrockCohereTokenizer = field(default=Factory(lambda self: BedrockCohereTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
try_embed_chunk(chunk)
Source code in griptape/drivers/embedding/amazon_bedrock_cohere_embedding_driver.py
AmazonBedrockImageGenerationDriver
Bases: BaseMultiModelImageGenerationDriver
Driver for image generation models provided by Amazon Bedrock.
Attributes:
Name | Type | Description |
---|---|---|
model |
Bedrock model ID. |
|
session |
Session
|
boto3 session. |
bedrock_client |
Any
|
Bedrock runtime client. |
image_width |
int
|
Width of output images. Defaults to 512 and must be a multiple of 64. |
image_height |
int
|
Height of output images. Defaults to 512 and must be a multiple of 64. |
seed |
Optional[int]
|
Optionally provide a consistent seed to generation requests, increasing consistency in output. |
Source code in griptape/drivers/image_generation/amazon_bedrock_image_generation_driver.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
bedrock_client: Any = field(default=Factory(lambda self: self.session.client(service_name='bedrock-runtime'), takes_self=True))
class-attribute
instance-attribute
image_height: int = field(default=512, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
image_width: int = field(default=512, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
seed: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
try_image_inpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/amazon_bedrock_image_generation_driver.py
try_image_outpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/amazon_bedrock_image_generation_driver.py
try_image_variation(prompts, image, negative_prompts=None)
Source code in griptape/drivers/image_generation/amazon_bedrock_image_generation_driver.py
try_text_to_image(prompts, negative_prompts=None)
Source code in griptape/drivers/image_generation/amazon_bedrock_image_generation_driver.py
AmazonBedrockImageQueryDriver
Bases: BaseMultiModelImageQueryDriver
Source code in griptape/drivers/image_query/amazon_bedrock_image_query_driver.py
bedrock_client: Any = field(default=Factory(lambda self: self.session.client('bedrock-runtime'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
try_query(query, images)
Source code in griptape/drivers/image_query/amazon_bedrock_image_query_driver.py
AmazonBedrockPromptDriver
Bases: BaseMultiModelPromptDriver
Source code in griptape/drivers/prompt/amazon_bedrock_prompt_driver.py
bedrock_client: Any = field(default=Factory(lambda self: self.session.client('bedrock-runtime'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
try_run(prompt_stack)
Source code in griptape/drivers/prompt/amazon_bedrock_prompt_driver.py
try_stream(prompt_stack)
Source code in griptape/drivers/prompt/amazon_bedrock_prompt_driver.py
AmazonBedrockTitanEmbeddingDriver
Bases: BaseEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
Embedding model name. Defaults to DEFAULT_MODEL. |
tokenizer |
BedrockTitanTokenizer
|
Optionally provide custom |
session |
Session
|
Optionally provide custom |
bedrock_client |
Any
|
Optionally provide custom |
Source code in griptape/drivers/embedding/amazon_bedrock_titan_embedding_driver.py
DEFAULT_MODEL = 'amazon.titan-embed-text-v1'
class-attribute
instance-attribute
bedrock_client: Any = field(default=Factory(lambda self: self.session.client('bedrock-runtime'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
model: str = field(default=DEFAULT_MODEL, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
tokenizer: BedrockTitanTokenizer = field(default=Factory(lambda self: BedrockTitanTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
try_embed_chunk(chunk)
Source code in griptape/drivers/embedding/amazon_bedrock_titan_embedding_driver.py
AmazonDynamoDbConversationMemoryDriver
Bases: BaseConversationMemoryDriver
Source code in griptape/drivers/memory/conversation/amazon_dynamodb_conversation_memory_driver.py
partition_key: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
partition_key_value: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
table: Any = field(init=False)
class-attribute
instance-attribute
table_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
value_attribute_key: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__attrs_post_init__()
load()
Source code in griptape/drivers/memory/conversation/amazon_dynamodb_conversation_memory_driver.py
store(memory)
Source code in griptape/drivers/memory/conversation/amazon_dynamodb_conversation_memory_driver.py
AmazonOpenSearchVectorStoreDriver
Bases: OpenSearchVectorStoreDriver
A Vector Store Driver for Amazon OpenSearch.
Attributes:
Name | Type | Description |
---|---|---|
session |
Session
|
The boto3 session to use. |
service |
str
|
Service name for AWS Signature v4. Values can be 'es' or 'aoss' for for OpenSearch Serverless. Defaults to 'es'. |
http_auth |
str | tuple[str, str]
|
The HTTP authentication credentials to use. Defaults to using credentials in the boto3 session. |
client |
OpenSearch
|
An optional OpenSearch client to use. Defaults to a new client using the host, port, http_auth, use_ssl, and verify_certs attributes. |
Source code in griptape/drivers/vector/amazon_opensearch_vector_store_driver.py
client: OpenSearch = field(default=Factory(lambda self: import_optional_dependency('opensearchpy').OpenSearch(hosts=[{'host': self.host, 'port': self.port}], http_auth=self.http_auth, use_ssl=self.use_ssl, verify_certs=self.verify_certs, connection_class=import_optional_dependency('opensearchpy').RequestsHttpConnection), takes_self=True))
class-attribute
instance-attribute
http_auth: str | tuple[str, str] = field(default=Factory(lambda self: import_optional_dependency('opensearchpy').AWSV4SignerAuth(self.session.get_credentials(), self.session.region_name, self.service), takes_self=True))
class-attribute
instance-attribute
service: str = field(default='es', kw_only=True)
class-attribute
instance-attribute
session: Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Inserts or updates a vector in OpenSearch.
If a vector with the given vector ID already exists, it is updated; otherwise, a new vector is inserted. Metadata associated with the vector can also be provided.
Source code in griptape/drivers/vector/amazon_opensearch_vector_store_driver.py
AmazonRedshiftSqlDriver
Bases: BaseSqlDriver
Source code in griptape/drivers/sql/amazon_redshift_sql_driver.py
client: Any = field(default=Factory(lambda self: self.session.client('redshift-data'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
cluster_identifier: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
database: str = field(kw_only=True)
class-attribute
instance-attribute
database_credentials_secret_arn: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
db_user: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(kw_only=True)
class-attribute
instance-attribute
wait_for_query_completion_sec: float = field(default=0.3, kw_only=True)
class-attribute
instance-attribute
workgroup_name: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
execute_query(query)
execute_query_raw(query)
Source code in griptape/drivers/sql/amazon_redshift_sql_driver.py
get_table_schema(table_name, schema=None)
Source code in griptape/drivers/sql/amazon_redshift_sql_driver.py
validate_params(_, workgroup_name)
Source code in griptape/drivers/sql/amazon_redshift_sql_driver.py
AmazonS3FileManagerDriver
Bases: BaseFileManagerDriver
AmazonS3FileManagerDriver can be used to list, load, and save files in an Amazon S3 bucket.
Attributes:
Name | Type | Description |
---|---|---|
session |
Session
|
The boto3 session to use for S3 operations. |
bucket |
str
|
The name of the S3 bucket. |
workdir |
str
|
The absolute working directory (must start with "/"). List, load, and save operations will be performed relative to this directory. |
s3_client |
Any
|
The S3 client to use for S3 operations. |
Source code in griptape/drivers/file_manager/amazon_s3_file_manager_driver.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
bucket: str = field(kw_only=True)
class-attribute
instance-attribute
s3_client: Any = field(default=Factory(lambda self: self.session.client('s3'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
workdir: str = field(default='/', kw_only=True)
class-attribute
instance-attribute
try_list_files(path)
Source code in griptape/drivers/file_manager/amazon_s3_file_manager_driver.py
try_load_file(path)
Source code in griptape/drivers/file_manager/amazon_s3_file_manager_driver.py
try_save_file(path, value)
Source code in griptape/drivers/file_manager/amazon_s3_file_manager_driver.py
AmazonSageMakerEmbeddingDriver
Bases: BaseMultiModelEmbeddingDriver
Source code in griptape/drivers/embedding/amazon_sagemaker_embedding_driver.py
embedding_model_driver: BaseEmbeddingModelDriver = field(kw_only=True)
class-attribute
instance-attribute
sagemaker_client: Any = field(default=Factory(lambda self: self.session.client('sagemaker-runtime'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
try_embed_chunk(chunk)
Source code in griptape/drivers/embedding/amazon_sagemaker_embedding_driver.py
AmazonSageMakerPromptDriver
Bases: BaseMultiModelPromptDriver
Source code in griptape/drivers/prompt/amazon_sagemaker_prompt_driver.py
custom_attributes: str = field(default='accept_eula=true', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
sagemaker_client: Any = field(default=Factory(lambda self: self.session.client('sagemaker-runtime'), takes_self=True), kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
stream: bool = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_run(prompt_stack)
Source code in griptape/drivers/prompt/amazon_sagemaker_prompt_driver.py
try_stream(prompt_stack)
AmazonSqsEventListenerDriver
Bases: BaseEventListenerDriver
Source code in griptape/drivers/event_listener/amazon_sqs_event_listener_driver.py
queue_url: str = field(kw_only=True)
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
sqs_client: Any = field(default=Factory(lambda self: self.session.client('sqs'), takes_self=True))
class-attribute
instance-attribute
AnthropicImageQueryDriver
Bases: BaseImageQueryDriver
Attributes:
Name | Type | Description |
---|---|---|
api_key |
Optional[str]
|
Anthropic API key. |
model |
str
|
Anthropic model name. |
client |
Any
|
Custom |
Source code in griptape/drivers/image_query/anthropic_image_query_driver.py
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
client: Any = field(default=Factory(lambda self: import_optional_dependency('anthropic').Anthropic(api_key=self.api_key), takes_self=True), kw_only=True)
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_query(query, images)
Source code in griptape/drivers/image_query/anthropic_image_query_driver.py
AnthropicPromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
api_key |
Optional[str]
|
Anthropic API key. |
model |
str
|
Anthropic model name. |
client |
Any
|
Custom |
tokenizer |
AnthropicTokenizer
|
Custom |
Source code in griptape/drivers/prompt/anthropic_prompt_driver.py
api_key: Optional[str] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
client: Any = field(default=Factory(lambda self: import_optional_dependency('anthropic').Anthropic(api_key=self.api_key), takes_self=True), kw_only=True)
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: AnthropicTokenizer = field(default=Factory(lambda self: AnthropicTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
top_k: int = field(default=250, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
top_p: float = field(default=0.999, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__to_anthropic_role(prompt_input)
try_run(prompt_stack)
try_stream(prompt_stack)
Source code in griptape/drivers/prompt/anthropic_prompt_driver.py
AwsIotCoreEventListenerDriver
Bases: BaseEventListenerDriver
Source code in griptape/drivers/event_listener/aws_iot_core_event_listener_driver.py
iot_endpoint: str = field(kw_only=True)
class-attribute
instance-attribute
iotdata_client: Any = field(default=Factory(lambda self: self.session.client('iot-data'), takes_self=True))
class-attribute
instance-attribute
session: boto3.Session = field(default=Factory(lambda: import_optional_dependency('boto3').Session()), kw_only=True)
class-attribute
instance-attribute
topic: str = field(kw_only=True)
class-attribute
instance-attribute
AzureMongoDbVectorStoreDriver
Bases: MongoDbAtlasVectorStoreDriver
A Vector Store Driver for CosmosDB with MongoDB vCore API.
Source code in griptape/drivers/vector/azure_mongodb_vector_store_driver.py
query(query, count=None, namespace=None, include_vectors=False, offset=None, **kwargs)
Queries the MongoDB collection for documents that match the provided query string.
Results can be customized based on parameters like count, namespace, inclusion of vectors, offset, and index.
Source code in griptape/drivers/vector/azure_mongodb_vector_store_driver.py
AzureOpenAiChatPromptDriver
Bases: OpenAiChatPromptDriver
Attributes:
Name | Type | Description |
---|---|---|
azure_deployment |
str
|
An Azure OpenAi deployment id. |
azure_endpoint |
str
|
An Azure OpenAi endpoint. |
azure_ad_token |
Optional[str]
|
An optional Azure Active Directory token. |
azure_ad_token_provider |
Optional[Callable[[], str]]
|
An optional Azure Active Directory token provider. |
api_version |
str
|
An Azure OpenAi API version. |
client |
AzureOpenAI
|
An |
Source code in griptape/drivers/prompt/azure_openai_chat_prompt_driver.py
api_version: str = field(default='2023-05-15', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token: Optional[str] = field(kw_only=True, default=None, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token_provider: Optional[Callable[[], str]] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
azure_deployment: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_endpoint: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.AzureOpenAI = field(default=Factory(lambda self: openai.AzureOpenAI(organization=self.organization, api_key=self.api_key, api_version=self.api_version, azure_endpoint=self.azure_endpoint, azure_deployment=self.azure_deployment, azure_ad_token=self.azure_ad_token, azure_ad_token_provider=self.azure_ad_token_provider), takes_self=True))
class-attribute
instance-attribute
AzureOpenAiCompletionPromptDriver
Bases: OpenAiCompletionPromptDriver
Attributes:
Name | Type | Description |
---|---|---|
azure_deployment |
str
|
An Azure OpenAi deployment id. |
azure_endpoint |
str
|
An Azure OpenAi endpoint. |
azure_ad_token |
Optional[str]
|
An optional Azure Active Directory token. |
azure_ad_token_provider |
Optional[Callable[[], str]]
|
An optional Azure Active Directory token provider. |
api_version |
str
|
An Azure OpenAi API version. |
client |
AzureOpenAI
|
An |
Source code in griptape/drivers/prompt/azure_openai_completion_prompt_driver.py
api_version: str = field(default='2023-05-15', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token: Optional[str] = field(kw_only=True, default=None, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token_provider: Optional[Callable[[], str]] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
azure_deployment: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_endpoint: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.AzureOpenAI = field(default=Factory(lambda self: openai.AzureOpenAI(organization=self.organization, api_key=self.api_key, api_version=self.api_version, azure_endpoint=self.azure_endpoint, azure_deployment=self.azure_deployment, azure_ad_token=self.azure_ad_token, azure_ad_token_provider=self.azure_ad_token_provider), takes_self=True))
class-attribute
instance-attribute
AzureOpenAiEmbeddingDriver
Bases: OpenAiEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
azure_deployment |
str
|
An Azure OpenAi deployment id. |
azure_endpoint |
str
|
An Azure OpenAi endpoint. |
azure_ad_token |
Optional[str]
|
An optional Azure Active Directory token. |
azure_ad_token_provider |
Optional[Callable[[], str]]
|
An optional Azure Active Directory token provider. |
api_version |
str
|
An Azure OpenAi API version. |
tokenizer |
OpenAiTokenizer
|
An |
client |
AzureOpenAI
|
An |
Source code in griptape/drivers/embedding/azure_openai_embedding_driver.py
api_version: str = field(default='2023-05-15', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token: Optional[str] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
azure_ad_token_provider: Optional[Callable[[], str]] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
azure_deployment: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_endpoint: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.AzureOpenAI = field(default=Factory(lambda self: openai.AzureOpenAI(organization=self.organization, api_key=self.api_key, api_version=self.api_version, azure_endpoint=self.azure_endpoint, azure_deployment=self.azure_deployment, azure_ad_token=self.azure_ad_token, azure_ad_token_provider=self.azure_ad_token_provider), takes_self=True))
class-attribute
instance-attribute
tokenizer: OpenAiTokenizer = field(default=Factory(lambda self: OpenAiTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
AzureOpenAiImageGenerationDriver
Bases: OpenAiImageGenerationDriver
Driver for Azure-hosted OpenAI image generation API.
Attributes:
Name | Type | Description |
---|---|---|
azure_deployment |
str
|
An Azure OpenAi deployment id. |
azure_endpoint |
str
|
An Azure OpenAi endpoint. |
azure_ad_token |
Optional[str]
|
An optional Azure Active Directory token. |
azure_ad_token_provider |
Optional[Callable[[], str]]
|
An optional Azure Active Directory token provider. |
api_version |
str
|
An Azure OpenAi API version. |
client |
AzureOpenAI
|
An |
Source code in griptape/drivers/image_generation/azure_openai_image_generation_driver.py
api_version: str = field(default='2024-02-01', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token: Optional[str] = field(kw_only=True, default=None, metadata={'serializable': True})
class-attribute
instance-attribute
azure_ad_token_provider: Optional[Callable[[], str]] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
azure_deployment: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
azure_endpoint: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.AzureOpenAI = field(default=Factory(lambda self: openai.AzureOpenAI(organization=self.organization, api_key=self.api_key, api_version=self.api_version, azure_endpoint=self.azure_endpoint, azure_deployment=self.azure_deployment, azure_ad_token=self.azure_ad_token, azure_ad_token_provider=self.azure_ad_token_provider), takes_self=True))
class-attribute
instance-attribute
BaseConversationMemoryDriver
Bases: SerializableMixin
, ABC
Source code in griptape/drivers/memory/conversation/base_conversation_memory_driver.py
load()
abstractmethod
BaseEmbeddingDriver
Bases: SerializableMixin
, ExponentialBackoffMixin
, ABC
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
The name of the model to use. |
tokenizer |
Optional[BaseTokenizer]
|
An instance of |
Source code in griptape/drivers/embedding/base_embedding_driver.py
chunker: BaseChunker = field(init=False)
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: Optional[BaseTokenizer] = field(default=None, kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
embed_string(string)
Source code in griptape/drivers/embedding/base_embedding_driver.py
embed_text_artifact(artifact)
BaseEmbeddingModelDriver
Bases: ABC
Source code in griptape/drivers/embedding_model/base_embedding_model_driver.py
chunk_to_model_params(chunk)
abstractmethod
BaseEventListenerDriver
Bases: ABC
Source code in griptape/drivers/event_listener/base_event_listener_driver.py
futures_executor: futures.Executor = field(default=Factory(lambda: futures.ThreadPoolExecutor()), kw_only=True)
class-attribute
instance-attribute
publish_event(event)
Source code in griptape/drivers/event_listener/base_event_listener_driver.py
BaseFileManagerDriver
Bases: ABC
BaseFileManagerDriver can be used to list, load, and save files.
Attributes:
Name | Type | Description |
---|---|---|
default_loader |
BaseLoader
|
The default loader to use for loading file contents into artifacts. |
loaders |
dict[str, BaseLoader]
|
Dictionary of file extension specifc loaders to use for loading file contents into artifacts. |
Source code in griptape/drivers/file_manager/base_file_manager_driver.py
default_loader: loaders.BaseLoader = field(default=Factory(lambda: loaders.BlobLoader()), kw_only=True)
class-attribute
instance-attribute
loaders: dict[str, loaders.BaseLoader] = field(default=Factory(lambda: {'pdf': loaders.PdfLoader(), 'csv': loaders.CsvLoader(), 'txt': loaders.TextLoader(), 'html': loaders.TextLoader(), 'json': loaders.TextLoader(), 'yaml': loaders.TextLoader(), 'xml': loaders.TextLoader(), 'png': loaders.ImageLoader(), 'jpg': loaders.ImageLoader(), 'jpeg': loaders.ImageLoader(), 'webp': loaders.ImageLoader(), 'gif': loaders.ImageLoader(), 'bmp': loaders.ImageLoader(), 'tiff': loaders.ImageLoader()}), kw_only=True)
class-attribute
instance-attribute
list_files(path)
Source code in griptape/drivers/file_manager/base_file_manager_driver.py
load_file(path)
Source code in griptape/drivers/file_manager/base_file_manager_driver.py
save_file(path, value)
Source code in griptape/drivers/file_manager/base_file_manager_driver.py
try_list_files(path)
abstractmethod
try_load_file(path)
abstractmethod
BaseImageGenerationDriver
Bases: SerializableMixin
, ExponentialBackoffMixin
, ABC
Source code in griptape/drivers/image_generation/base_image_generation_driver.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
structure: Optional[Structure] = field(default=None, kw_only=True)
class-attribute
instance-attribute
after_run()
before_run(prompts, negative_prompts=None)
Source code in griptape/drivers/image_generation/base_image_generation_driver.py
run_image_inpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/base_image_generation_driver.py
run_image_outpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/base_image_generation_driver.py
run_image_variation(prompts, image, negative_prompts=None)
Source code in griptape/drivers/image_generation/base_image_generation_driver.py
run_text_to_image(prompts, negative_prompts=None)
Source code in griptape/drivers/image_generation/base_image_generation_driver.py
try_image_inpainting(prompts, image, mask, negative_prompts=None)
abstractmethod
try_image_outpainting(prompts, image, mask, negative_prompts=None)
abstractmethod
try_image_variation(prompts, image, negative_prompts=None)
abstractmethod
BaseImageGenerationModelDriver
Bases: SerializableMixin
, ABC
Source code in griptape/drivers/image_generation_model/base_image_generation_model_driver.py
get_generated_image(response)
abstractmethod
image_inpainting_request_parameters(prompts, image, mask, negative_prompts=None, seed=None)
abstractmethod
Source code in griptape/drivers/image_generation_model/base_image_generation_model_driver.py
image_outpainting_request_parameters(prompts, image, mask, negative_prompts=None, seed=None)
abstractmethod
Source code in griptape/drivers/image_generation_model/base_image_generation_model_driver.py
image_variation_request_parameters(prompts, image, negative_prompts=None, seed=None)
abstractmethod
Source code in griptape/drivers/image_generation_model/base_image_generation_model_driver.py
text_to_image_request_parameters(prompts, image_width, image_height, negative_prompts=None, seed=None)
abstractmethod
Source code in griptape/drivers/image_generation_model/base_image_generation_model_driver.py
BaseImageQueryDriver
Bases: SerializableMixin
, ExponentialBackoffMixin
, ABC
Source code in griptape/drivers/image_query/base_image_query_driver.py
max_tokens: int = field(default=256, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
structure: Optional[Structure] = field(default=None, kw_only=True)
class-attribute
instance-attribute
after_run(result)
before_run(query, images)
query(query, images)
Source code in griptape/drivers/image_query/base_image_query_driver.py
BaseImageQueryModelDriver
Bases: SerializableMixin
, ABC
Source code in griptape/drivers/image_query_model/base_image_query_model_driver.py
image_query_request_parameters(query, images, max_tokens)
abstractmethod
BaseMultiModelEmbeddingDriver
Bases: BaseEmbeddingDriver
, ABC
Source code in griptape/drivers/embedding/base_multi_model_embedding_driver.py
embedding_model_driver: BaseEmbeddingModelDriver = field(kw_only=True)
class-attribute
instance-attribute
BaseMultiModelImageGenerationDriver
Bases: BaseImageGenerationDriver
, ABC
Image Generation Driver for platforms like Amazon Bedrock that host many LLM models.
Instances of this Image Generation Driver require a Image Generation Model Driver which is used to structure the image generation request in the format required by the model and to process the output.
Attributes:
Name | Type | Description |
---|---|---|
image_generation_model_driver |
BaseImageGenerationModelDriver
|
Image Model Driver to use. |
Source code in griptape/drivers/image_generation/base_multi_model_image_generation_driver.py
image_generation_model_driver: BaseImageGenerationModelDriver = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
BaseMultiModelImageQueryDriver
Bases: BaseImageQueryDriver
, ABC
Image Query Driver for platforms like Amazon Bedrock that host many LLM models.
Instances of this Image Query Driver require a Image Query Model Driver which is used to structure the image generation request in the format required by the model and to process the output.
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
Model name to use |
image_query_model_driver |
BaseImageQueryModelDriver
|
Image Model Driver to use. |
Source code in griptape/drivers/image_query/base_multi_model_image_query_driver.py
image_query_model_driver: BaseImageQueryModelDriver = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
BaseMultiModelPromptDriver
Bases: BasePromptDriver
, ABC
Prompt Driver for platforms like Amazon SageMaker, and Amazon Bedrock that host many LLM models.
Instances of this Prompt Driver require a Prompt Model Driver which is used to convert the prompt stack into a model input and parameters, and to process the model output.
Attributes:
Name | Type | Description |
---|---|---|
model |
Name of the model to use. |
|
tokenizer |
Optional[BaseTokenizer]
|
Tokenizer to use. Defaults to the Tokenizer of the Prompt Model Driver. |
prompt_model_driver |
BasePromptModelDriver
|
Prompt Model Driver to use. |
Source code in griptape/drivers/prompt/base_multi_model_prompt_driver.py
prompt_model_driver: BasePromptModelDriver = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
stream: bool = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: Optional[BaseTokenizer] = field(default=None, kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
validate_stream(_, stream)
Source code in griptape/drivers/prompt/base_multi_model_prompt_driver.py
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 |
Callable[[PromptStack], 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
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
prompt_stack_to_string: Callable[[PromptStack], str] = field(default=Factory(lambda self: self.default_prompt_stack_to_string_converter, takes_self=True), kw_only=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
default_prompt_stack_to_string_converter(prompt_stack)
Source code in griptape/drivers/prompt/base_prompt_driver.py
max_output_tokens(text)
run(prompt_stack)
Source code in griptape/drivers/prompt/base_prompt_driver.py
token_count(prompt_stack)
try_run(prompt_stack)
abstractmethod
BasePromptModelDriver
Bases: SerializableMixin
, ABC
Source code in griptape/drivers/prompt_model/base_prompt_model_driver.py
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
prompt_stack_to_model_input(prompt_stack)
abstractmethod
BaseSqlDriver
Bases: ABC
Source code in griptape/drivers/sql/base_sql_driver.py
RowResult
dataclass
execute_query(query)
abstractmethod
execute_query_raw(query)
abstractmethod
BaseStructureRunDriver
Bases: ABC
Source code in griptape/drivers/structure_run/base_structure_run_driver.py
run(*args)
BaseVectorStoreDriver
Bases: SerializableMixin
, ABC
Source code in griptape/drivers/vector/base_vector_store_driver.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
DEFAULT_QUERY_COUNT = 5
class-attribute
instance-attribute
embedding_driver: BaseEmbeddingDriver = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
futures_executor: futures.Executor = field(default=Factory(lambda: futures.ThreadPoolExecutor()), kw_only=True)
class-attribute
instance-attribute
Entry
dataclass
Source code in griptape/drivers/vector/base_vector_store_driver.py
id: str
instance-attribute
meta: Optional[dict] = None
class-attribute
instance-attribute
namespace: Optional[str] = None
class-attribute
instance-attribute
vector: list[float]
instance-attribute
__init__(id, vector, meta=None, namespace=None)
QueryResult
dataclass
Source code in griptape/drivers/vector/base_vector_store_driver.py
id: str
instance-attribute
meta: Optional[dict] = None
class-attribute
instance-attribute
namespace: Optional[str] = None
class-attribute
instance-attribute
score: float
instance-attribute
vector: Optional[list[float]]
instance-attribute
__init__(id, vector, score, meta=None, namespace=None)
delete_vector(vector_id)
abstractmethod
load_entries(namespace=None)
abstractmethod
load_entry(vector_id, namespace=None)
abstractmethod
query(query, count=None, namespace=None, include_vectors=False, **kwargs)
abstractmethod
upsert_text(string, vector_id=None, namespace=None, meta=None, **kwargs)
Source code in griptape/drivers/vector/base_vector_store_driver.py
upsert_text_artifact(artifact, namespace=None, meta=None, **kwargs)
Source code in griptape/drivers/vector/base_vector_store_driver.py
upsert_text_artifacts(artifacts, meta=None, **kwargs)
Source code in griptape/drivers/vector/base_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
abstractmethod
BaseWebScraperDriver
Bases: ABC
Source code in griptape/drivers/web_scraper/base_web_scraper_driver.py
BedrockClaudeImageQueryModelDriver
Bases: BaseImageQueryModelDriver
Source code in griptape/drivers/image_query_model/bedrock_claude_image_query_model_driver.py
ANTHROPIC_VERSION = 'bedrock-2023-05-31'
class-attribute
instance-attribute
image_query_request_parameters(query, images, max_tokens)
Source code in griptape/drivers/image_query_model/bedrock_claude_image_query_model_driver.py
process_output(output)
Source code in griptape/drivers/image_query_model/bedrock_claude_image_query_model_driver.py
BedrockClaudePromptModelDriver
Bases: BasePromptModelDriver
Source code in griptape/drivers/prompt_model/bedrock_claude_prompt_model_driver.py
ANTHROPIC_VERSION = 'bedrock-2023-05-31'
class-attribute
instance-attribute
prompt_driver: Optional[AmazonBedrockPromptDriver] = field(default=None, kw_only=True)
class-attribute
instance-attribute
tokenizer: BedrockClaudeTokenizer
property
Returns the tokenizer for this driver.
We need to pass the session
field from the Prompt Driver to the
Tokenizer. However, the Prompt Driver is not initialized until after
the Prompt Model Driver is initialized. To resolve this, we make the tokenizer
field a @property that is only initialized when it is first accessed.
This ensures that by the time we need to initialize the Tokenizer, the
Prompt Driver has already been initialized.
See this thread more more information: https://github.com/griptape-ai/griptape/issues/244
Returns:
Name | Type | Description |
---|---|---|
BedrockClaudeTokenizer |
BedrockClaudeTokenizer
|
The tokenizer for this driver. |
top_k: int = field(default=250, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
top_p: float = field(default=0.999, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__to_anthropic_role(prompt_input)
process_output(output)
Source code in griptape/drivers/prompt_model/bedrock_claude_prompt_model_driver.py
prompt_stack_to_model_input(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_claude_prompt_model_driver.py
prompt_stack_to_model_params(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_claude_prompt_model_driver.py
BedrockJurassicPromptModelDriver
Bases: BasePromptModelDriver
Source code in griptape/drivers/prompt_model/bedrock_jurassic_prompt_model_driver.py
prompt_driver: Optional[AmazonBedrockPromptDriver] = field(default=None, kw_only=True)
class-attribute
instance-attribute
supports_streaming: bool = field(default=False, kw_only=True)
class-attribute
instance-attribute
tokenizer: BedrockJurassicTokenizer
property
Returns the tokenizer for this driver.
We need to pass the session
field from the Prompt Driver to the
Tokenizer. However, the Prompt Driver is not initialized until after
the Prompt Model Driver is initialized. To resolve this, we make the tokenizer
field a @property that is only initialized when it is first accessed.
This ensures that by the time we need to initialize the Tokenizer, the
Prompt Driver has already been initialized.
See this thread more more information: https://github.com/griptape-ai/griptape/issues/244
Returns:
Name | Type | Description |
---|---|---|
BedrockJurassicTokenizer |
BedrockJurassicTokenizer
|
The tokenizer for this driver. |
top_p: float = field(default=0.9, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
process_output(output)
Source code in griptape/drivers/prompt_model/bedrock_jurassic_prompt_model_driver.py
prompt_stack_to_model_input(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_jurassic_prompt_model_driver.py
prompt_stack_to_model_params(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_jurassic_prompt_model_driver.py
BedrockLlamaPromptModelDriver
Bases: BasePromptModelDriver
Source code in griptape/drivers/prompt_model/bedrock_llama_prompt_model_driver.py
prompt_driver: Optional[AmazonBedrockPromptDriver] = field(default=None, kw_only=True)
class-attribute
instance-attribute
tokenizer: BedrockLlamaTokenizer
property
Returns the tokenizer for this driver.
We need to pass the session
field from the Prompt Driver to the
Tokenizer. However, the Prompt Driver is not initialized until after
the Prompt Model Driver is initialized. To resolve this, we make the tokenizer
field a @property that is only initialized when it is first accessed.
This ensures that by the time we need to initialize the Tokenizer, the
Prompt Driver has already been initialized.
See this thread more more information: https://github.com/griptape-ai/griptape/issues/244
Returns:
Name | Type | Description |
---|---|---|
BedrockLlamaTokenizer |
BedrockLlamaTokenizer
|
The tokenizer for this driver. |
top_p: float = field(default=0.9, kw_only=True)
class-attribute
instance-attribute
process_output(output)
Source code in griptape/drivers/prompt_model/bedrock_llama_prompt_model_driver.py
prompt_stack_to_model_input(prompt_stack)
Converts a PromptStack
to a string that can be used as the input to the model.
Prompt structure adapted from https://huggingface.co/blog/llama2#how-to-prompt-llama-2
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt_stack |
PromptStack
|
The |
required |
Source code in griptape/drivers/prompt_model/bedrock_llama_prompt_model_driver.py
prompt_stack_to_model_params(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_llama_prompt_model_driver.py
BedrockStableDiffusionImageGenerationModelDriver
Bases: BaseImageGenerationModelDriver
Image generation model driver for Stable Diffusion models on Amazon Bedrock.
For more information on all supported parameters, see the Stable Diffusion documentation: https://platform.stability.ai/docs/api-reference#tag/v1generation
Attributes:
Name | Type | Description |
---|---|---|
cfg_scale |
int
|
Specifies how strictly image generation follows the provided prompt. Defaults to 7. |
mask_source |
int
|
Specifies mask image configuration for image-to-image generations. Defaults to "MASK_IMAGE_BLACK". |
style_preset |
Optional[str]
|
If provided, specifies a specific image generation style preset. |
clip_guidance_preset |
Optional[str]
|
If provided, requests a specific clip guidance preset to be used in the diffusion process. |
sampler |
Optional[str]
|
If provided, requests a specific sampler to be used in the diffusion process. |
steps |
Optional[int]
|
If provided, specifies the number of diffusion steps to use in the image generation. |
start_schedule |
Optional[float]
|
If provided, specifies the start_schedule parameter used to determine the influence of the input image in image-to-image generation. |
Source code in griptape/drivers/image_generation_model/bedrock_stable_diffusion_image_generation_model_driver.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
cfg_scale: int = field(default=7, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
clip_guidance_preset: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
sampler: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
start_schedule: Optional[float] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
steps: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
style_preset: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
get_generated_image(response)
Source code in griptape/drivers/image_generation_model/bedrock_stable_diffusion_image_generation_model_driver.py
image_inpainting_request_parameters(prompts, image, mask, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_stable_diffusion_image_generation_model_driver.py
image_outpainting_request_parameters(prompts, image, mask, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_stable_diffusion_image_generation_model_driver.py
image_variation_request_parameters(prompts, image, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_stable_diffusion_image_generation_model_driver.py
text_to_image_request_parameters(prompts, image_width, image_height, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_stable_diffusion_image_generation_model_driver.py
BedrockTitanImageGenerationModelDriver
Bases: BaseImageGenerationModelDriver
Image Generation Model Driver for Amazon Bedrock Titan Image Generator.
Attributes:
Name | Type | Description |
---|---|---|
quality |
str
|
The quality of the generated image, defaults to standard. |
cfg_scale |
int
|
Specifies how strictly image generation follows the provided prompt. Defaults to 7, (1.0 to 10.0]. |
outpainting_mode |
str
|
Specifies the outpainting mode, defaults to PRECISE. |
Source code in griptape/drivers/image_generation_model/bedrock_titan_image_generation_model_driver.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
cfg_scale: int = field(default=7, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
outpainting_mode: str = field(default='PRECISE', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
quality: str = field(default='standard', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
get_generated_image(response)
image_inpainting_request_parameters(prompts, image, mask, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_titan_image_generation_model_driver.py
image_outpainting_request_parameters(prompts, image, mask, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_titan_image_generation_model_driver.py
image_variation_request_parameters(prompts, image, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_titan_image_generation_model_driver.py
text_to_image_request_parameters(prompts, image_width, image_height, negative_prompts=None, seed=None)
Source code in griptape/drivers/image_generation_model/bedrock_titan_image_generation_model_driver.py
BedrockTitanPromptModelDriver
Bases: BasePromptModelDriver
Source code in griptape/drivers/prompt_model/bedrock_titan_prompt_model_driver.py
prompt_driver: Optional[AmazonBedrockPromptDriver] = field(default=None, kw_only=True)
class-attribute
instance-attribute
tokenizer: BedrockTitanTokenizer
property
Returns the tokenizer for this driver.
We need to pass the session
field from the Prompt Driver to the
Tokenizer. However, the Prompt Driver is not initialized until after
the Prompt Model Driver is initialized. To resolve this, we make the tokenizer
field a @property that is only initialized when it is first accessed.
This ensures that by the time we need to initialize the Tokenizer, the
Prompt Driver has already been initialized.
See this thread for more information: https://github.com/griptape-ai/griptape/issues/244
Returns:
Name | Type | Description |
---|---|---|
BedrockTitanTokenizer |
BedrockTitanTokenizer
|
The tokenizer for this driver. |
top_p: float = field(default=0.9, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
process_output(output)
Source code in griptape/drivers/prompt_model/bedrock_titan_prompt_model_driver.py
prompt_stack_to_model_input(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_titan_prompt_model_driver.py
prompt_stack_to_model_params(prompt_stack)
Source code in griptape/drivers/prompt_model/bedrock_titan_prompt_model_driver.py
CoherePromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
Cohere API key. |
model |
str
|
Cohere model name. |
client |
Client
|
Custom |
tokenizer |
CohereTokenizer
|
Custom |
Source code in griptape/drivers/prompt/cohere_prompt_driver.py
api_key: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: Client = field(default=Factory(lambda self: import_optional_dependency('cohere').Client(self.api_key), takes_self=True), kw_only=True)
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: CohereTokenizer = field(default=Factory(lambda self: CohereTokenizer(model=self.model, client=self.client), takes_self=True), kw_only=True)
class-attribute
instance-attribute
try_run(prompt_stack)
Source code in griptape/drivers/prompt/cohere_prompt_driver.py
try_stream(prompt_stack)
DummyEmbeddingDriver
Bases: BaseEmbeddingDriver
Source code in griptape/drivers/embedding/dummy_embedding_driver.py
DummyImageGenerationDriver
Bases: BaseImageGenerationDriver
Source code in griptape/drivers/image_generation/dummy_image_generation_driver.py
model: str = field(init=False)
class-attribute
instance-attribute
try_image_inpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/dummy_image_generation_driver.py
try_image_outpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/dummy_image_generation_driver.py
try_image_variation(prompts, image, negative_prompts=None)
try_text_to_image(prompts, negative_prompts=None)
DummyImageQueryDriver
Bases: BaseImageQueryDriver
Source code in griptape/drivers/image_query/dummy_image_query_driver.py
max_tokens: int = field(init=False)
class-attribute
instance-attribute
model: str = field(init=False)
class-attribute
instance-attribute
DummyPromptDriver
Bases: BasePromptDriver
Source code in griptape/drivers/prompt/dummy_prompt_driver.py
model: str = field(init=False)
class-attribute
instance-attribute
tokenizer: DummyTokenizer = field(default=Factory(lambda: DummyTokenizer()), kw_only=True)
class-attribute
instance-attribute
try_run(prompt_stack)
DummyVectorStoreDriver
Bases: BaseVectorStoreDriver
Source code in griptape/drivers/vector/dummy_vector_store_driver.py
embedding_driver: BaseEmbeddingDriver = field(kw_only=True, default=Factory(lambda: DummyEmbeddingDriver()), metadata={'serializable': True})
class-attribute
instance-attribute
delete_vector(vector_id)
load_entries(namespace=None)
load_entry(vector_id, namespace=None)
query(query, count=None, namespace=None, include_vectors=False, **kwargs)
Source code in griptape/drivers/vector/dummy_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Source code in griptape/drivers/vector/dummy_vector_store_driver.py
GoogleEmbeddingDriver
Bases: BaseEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
api_key |
Optional[str]
|
Google API key. |
model |
str
|
Google model name. |
task_type |
str
|
Embedding model task type (https://ai.google.dev/tutorials/python_quickstart#use_embeddings). Defaults to |
title |
Optional[str]
|
Optional title for the content. Only works with |
Source code in griptape/drivers/embedding/google_embedding_driver.py
DEFAULT_MODEL = 'models/embedding-001'
class-attribute
instance-attribute
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
model: str = field(default=DEFAULT_MODEL, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
task_type: str = field(default='retrieval_document', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
title: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_embed_chunk(chunk)
Source code in griptape/drivers/embedding/google_embedding_driver.py
GooglePromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
api_key |
Optional[str]
|
Google API key. |
model |
str
|
Google model name. |
model_client |
Any
|
Custom |
tokenizer |
BaseTokenizer
|
Custom |
top_p |
Optional[float]
|
Optional value for top_p. |
top_k |
Optional[int]
|
Optional value for top_k. |
Source code in griptape/drivers/prompt/google_prompt_driver.py
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model_client: Any = field(default=Factory(lambda self: self._default_model_client(), takes_self=True), kw_only=True)
class-attribute
instance-attribute
tokenizer: BaseTokenizer = field(default=Factory(lambda self: GoogleTokenizer(api_key=self.api_key, model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
top_k: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
top_p: Optional[float] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__to_content_dict(prompt_input)
Source code in griptape/drivers/prompt/google_prompt_driver.py
__to_google_role(prompt_input)
try_run(prompt_stack)
Source code in griptape/drivers/prompt/google_prompt_driver.py
try_stream(prompt_stack)
Source code in griptape/drivers/prompt/google_prompt_driver.py
GriptapeCloudEventListenerDriver
Bases: BaseEventListenerDriver
Driver for publishing events to Griptape Cloud.
Attributes:
Name | Type | Description |
---|---|---|
base_url |
str
|
The base URL of Griptape Cloud. Defaults to the GT_CLOUD_BASE_URL environment variable. |
api_key |
str
|
The API key to authenticate with Griptape Cloud. |
headers |
dict
|
The headers to use when making requests to Griptape Cloud. Defaults to include the Authorization header. |
structure_run_id |
str
|
The ID of the Structure Run to publish events to. Defaults to the GT_CLOUD_STRUCTURE_RUN_ID environment variable. |
Source code in griptape/drivers/event_listener/griptape_cloud_event_listener_driver.py
api_key: str = field(kw_only=True)
class-attribute
instance-attribute
base_url: str = field(default=Factory(lambda: os.getenv('GT_CLOUD_BASE_URL', 'https://cloud.griptape.ai')), kw_only=True)
class-attribute
instance-attribute
headers: dict = field(default=Factory(lambda self: {'Authorization': f'Bearer {self.api_key}'}, takes_self=True), kw_only=True)
class-attribute
instance-attribute
structure_run_id: str = field(default=Factory(lambda: os.getenv('GT_CLOUD_STRUCTURE_RUN_ID')), kw_only=True)
class-attribute
instance-attribute
try_publish_event_payload(event_payload)
Source code in griptape/drivers/event_listener/griptape_cloud_event_listener_driver.py
validate_run_id(_, structure_run_id)
Source code in griptape/drivers/event_listener/griptape_cloud_event_listener_driver.py
GriptapeCloudStructureRunDriver
Bases: BaseStructureRunDriver
Source code in griptape/drivers/structure_run/griptape_cloud_structure_run_driver.py
api_key: str = field(kw_only=True)
class-attribute
instance-attribute
async_run: bool = field(default=False, kw_only=True)
class-attribute
instance-attribute
base_url: str = field(default='https://cloud.griptape.ai', kw_only=True)
class-attribute
instance-attribute
headers: dict = field(default=Factory(lambda self: {'Authorization': f'Bearer {self.api_key}'}, takes_self=True), kw_only=True)
class-attribute
instance-attribute
structure_id: str = field(kw_only=True)
class-attribute
instance-attribute
structure_run_max_wait_time_attempts: int = field(default=20, kw_only=True)
class-attribute
instance-attribute
structure_run_wait_time_interval: int = field(default=2, kw_only=True)
class-attribute
instance-attribute
try_run(*args)
Source code in griptape/drivers/structure_run/griptape_cloud_structure_run_driver.py
HuggingFaceHubEmbeddingDriver
Bases: BaseEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
api_token |
str
|
Hugging Face Hub API token. |
model |
str
|
Hugging Face Hub model name. |
client |
InferenceClient
|
Custom |
Source code in griptape/drivers/embedding/huggingface_hub_embedding_driver.py
api_token: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: InferenceClient = field(default=Factory(lambda self: import_optional_dependency('huggingface_hub').InferenceClient(model=self.model, token=self.api_token), takes_self=True), kw_only=True)
class-attribute
instance-attribute
HuggingFaceHubPromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
api_token |
str
|
Hugging Face Hub API token. |
use_gpu |
str
|
Use GPU during model run. |
params |
dict
|
Custom model run parameters. |
model |
str
|
Hugging Face Hub model name. |
client |
InferenceClient
|
Custom |
tokenizer |
HuggingFaceTokenizer
|
Custom |
Source code in griptape/drivers/prompt/huggingface_hub_prompt_driver.py
api_token: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: InferenceClient = field(default=Factory(lambda self: import_optional_dependency('huggingface_hub').InferenceClient(model=self.model, token=self.api_token), takes_self=True), kw_only=True)
class-attribute
instance-attribute
max_tokens: int = field(default=250, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
params: dict = field(factory=dict, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: HuggingFaceTokenizer = field(default=Factory(lambda self: HuggingFaceTokenizer(tokenizer=import_optional_dependency('transformers').AutoTokenizer.from_pretrained(self.model), max_output_tokens=self.max_tokens), takes_self=True), kw_only=True)
class-attribute
instance-attribute
try_run(prompt_stack)
Source code in griptape/drivers/prompt/huggingface_hub_prompt_driver.py
try_stream(prompt_stack)
Source code in griptape/drivers/prompt/huggingface_hub_prompt_driver.py
HuggingFacePipelinePromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
params |
dict
|
Custom model run parameters. |
model |
str
|
Hugging Face Hub model name. |
tokenizer |
HuggingFaceTokenizer
|
Custom |
Source code in griptape/drivers/prompt/huggingface_pipeline_prompt_driver.py
DEFAULT_PARAMS = {'return_full_text': False, 'num_return_sequences': 1}
class-attribute
instance-attribute
SUPPORTED_TASKS = ['text2text-generation', 'text-generation']
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
params: dict = field(factory=dict, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: HuggingFaceTokenizer = field(default=Factory(lambda self: HuggingFaceTokenizer(tokenizer=import_optional_dependency('transformers').AutoTokenizer.from_pretrained(self.model), max_output_tokens=self.max_tokens), takes_self=True), kw_only=True)
class-attribute
instance-attribute
try_run(prompt_stack)
Source code in griptape/drivers/prompt/huggingface_pipeline_prompt_driver.py
LeonardoImageGenerationDriver
Bases: BaseImageGenerationDriver
Driver for the Leonardo image generation API.
Details on Leonardo image generation parameters can be found here: https://docs.leonardo.ai/reference/creategeneration
Attributes:
Name | Type | Description |
---|---|---|
model |
The ID of the model to use when generating images. |
|
api_key |
str
|
The API key to use when making requests to the Leonardo API. |
requests_session |
Session
|
The requests session to use when making requests to the Leonardo API. |
api_base |
str
|
The base URL of the Leonardo API. |
max_attempts |
int
|
The maximum number of times to poll the Leonardo API for a completed image. |
image_width |
int
|
The width of the generated image in the range [32, 1024] and divisible by 8. |
image_height |
int
|
The height of the generated image in the range [32, 1024] and divisible by 8. |
steps |
Optional[int]
|
Optionally specify the number of inference steps to run for each image generation request, [30, 60]. |
seed |
Optional[int]
|
Optionally provide a consistent seed to generation requests, increasing consistency in output. |
init_strength |
Optional[float]
|
Optionally specify the strength of the initial image, [0.0, 1.0]. |
Source code in griptape/drivers/image_generation/leonardo_image_generation_driver.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
api_base: str = 'https://cloud.leonardo.ai/api/rest/v1'
class-attribute
instance-attribute
api_key: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
control_net: bool = field(default=False, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
control_net_type: Optional[Literal['POSE', 'CANNY', 'DEPTH']] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
image_height: int = field(default=512, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
image_width: int = field(default=512, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
init_strength: Optional[float] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
max_attempts: int = field(default=10, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
requests_session: requests.Session = field(default=Factory(lambda: requests.Session()), kw_only=True)
class-attribute
instance-attribute
seed: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
steps: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_image_inpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/leonardo_image_generation_driver.py
try_image_outpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/leonardo_image_generation_driver.py
try_image_variation(prompts, image, negative_prompts=None)
Source code in griptape/drivers/image_generation/leonardo_image_generation_driver.py
try_text_to_image(prompts, negative_prompts=None)
Source code in griptape/drivers/image_generation/leonardo_image_generation_driver.py
LocalConversationMemoryDriver
Bases: BaseConversationMemoryDriver
Source code in griptape/drivers/memory/conversation/local_conversation_memory_driver.py
file_path: str = field(default='griptape_memory.json', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
load()
Source code in griptape/drivers/memory/conversation/local_conversation_memory_driver.py
LocalFileManagerDriver
Bases: BaseFileManagerDriver
LocalFileManagerDriver can be used to list, load, and save files on the local file system.
Attributes:
Name | Type | Description |
---|---|---|
workdir |
str
|
The absolute working directory. List, load, and save operations will be performed relative to this directory. |
Source code in griptape/drivers/file_manager/local_file_manager_driver.py
workdir: str = field(default=Factory(lambda: os.getcwd()), kw_only=True)
class-attribute
instance-attribute
try_list_files(path)
try_load_file(path)
try_save_file(path, value)
Source code in griptape/drivers/file_manager/local_file_manager_driver.py
LocalStructureRunDriver
Bases: BaseStructureRunDriver
Source code in griptape/drivers/structure_run/local_structure_run_driver.py
structure_factory_fn: Callable[[], Structure] = field(kw_only=True)
class-attribute
instance-attribute
try_run(*args)
Source code in griptape/drivers/structure_run/local_structure_run_driver.py
LocalVectorStoreDriver
Bases: BaseVectorStoreDriver
Source code in griptape/drivers/vector/local_vector_store_driver.py
entries: dict[str, BaseVectorStoreDriver.Entry] = field(factory=dict, kw_only=True)
class-attribute
instance-attribute
relatedness_fn: Callable = field(default=lambda x, y: dot(x, y) / norm(x) * norm(y), kw_only=True)
class-attribute
instance-attribute
delete_vector(vector_id)
load_entries(namespace=None)
load_entry(vector_id, namespace=None)
query(query, count=None, namespace=None, include_vectors=False, **kwargs)
Source code in griptape/drivers/vector/local_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Source code in griptape/drivers/vector/local_vector_store_driver.py
MarkdownifyWebScraperDriver
Bases: BaseWebScraperDriver
Driver to scrape a webpage and return the content in markdown format.
As a prerequisite to using MarkdownifyWebScraperDriver, you need to install the browsers used by
playwright. You can do this by running: poetry run playwright install
.
For more details about playwright, see https://playwright.dev/python/docs/library.
Attributes:
Name | Type | Description |
---|---|---|
include_links |
bool
|
If |
exclude_tags |
list[str]
|
Optionally provide custom tags to exclude from the scraped content. |
exclude_classes |
list[str]
|
Optionally provide custom classes to exclude from the scraped content. |
exclude_ids |
list[str]
|
Optionally provide custom ids to exclude from the scraped content. |
timeout |
Optional[int]
|
Optionally provide a timeout in milliseconds for the page to continue loading after the browser has emitted the "load" event. |
Source code in griptape/drivers/web_scraper/markdownify_web_scraper_driver.py
DEFAULT_EXCLUDE_TAGS = ['script', 'style', 'head']
class-attribute
instance-attribute
exclude_classes: list[str] = field(default=Factory(list), kw_only=True)
class-attribute
instance-attribute
exclude_ids: list[str] = field(default=Factory(list), kw_only=True)
class-attribute
instance-attribute
exclude_tags: list[str] = field(default=Factory(lambda self: self.DEFAULT_EXCLUDE_TAGS, takes_self=True), kw_only=True)
class-attribute
instance-attribute
include_links: bool = field(default=True, kw_only=True)
class-attribute
instance-attribute
timeout: Optional[int] = field(default=None, kw_only=True)
class-attribute
instance-attribute
scrape_url(url)
Source code in griptape/drivers/web_scraper/markdownify_web_scraper_driver.py
MarqoVectorStoreDriver
Bases: BaseVectorStoreDriver
A Vector Store Driver for Marqo.
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
The API key for the Marqo API. |
url |
str
|
The URL to the Marqo API. |
mq |
Optional[Client]
|
An optional Marqo client. Defaults to a new client with the given URL and API key. |
index |
str
|
The name of the index to use. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
api_key: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
index: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
mq: Optional[marqo.Client] = field(default=Factory(lambda self: import_optional_dependency('marqo').Client(self.url, api_key=self.api_key), takes_self=True), kw_only=True)
class-attribute
instance-attribute
url: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
delete_index(name)
Delete an index in the Marqo client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the index to delete. |
required |
delete_vector(vector_id)
get_indexes()
Get a list of all indexes in the Marqo client.
Returns:
Type | Description |
---|---|
list[str]
|
The list of all indexes. |
load_entries(namespace=None)
Load all document entries from the Marqo index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace |
Optional[str]
|
The namespace to filter entries by. |
None
|
Returns:
Type | Description |
---|---|
list[Entry]
|
The list of loaded Entries. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
load_entry(vector_id, namespace=None)
Load a document entry from the Marqo index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id |
str
|
The ID of the vector to load. |
required |
namespace |
Optional[str]
|
The namespace of the vector to load. |
None
|
Returns:
Type | Description |
---|---|
Optional[Entry]
|
The loaded Entry if found, otherwise None. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
query(query, count=None, namespace=None, include_vectors=False, include_metadata=True, **kwargs)
Query the Marqo index for documents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
The query string. |
required |
count |
Optional[int]
|
The maximum number of results to return. |
None
|
namespace |
Optional[str]
|
The namespace to filter results by. |
None
|
include_vectors |
bool
|
Whether to include vector data in the results. |
False
|
include_metadata |
bool
|
Whether to include metadata in the results. |
True
|
Returns:
Type | Description |
---|---|
list[QueryResult]
|
The list of query results. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
upsert_text(string, vector_id=None, namespace=None, meta=None, **kwargs)
Upsert a text document into the Marqo index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
The string to be indexed. |
required |
vector_id |
Optional[str]
|
The ID for the vector. If None, Marqo will generate an ID. |
None
|
namespace |
Optional[str]
|
An optional namespace for the document. |
None
|
meta |
Optional[dict]
|
An optional dictionary of metadata for the document. |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The ID of the document that was added. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
upsert_text_artifact(artifact, namespace=None, meta=None, **kwargs)
Upsert a text artifact into the Marqo index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact |
TextArtifact
|
The text artifact to be indexed. |
required |
namespace |
Optional[str]
|
An optional namespace for the artifact. |
None
|
meta |
Optional[dict]
|
An optional dictionary of metadata for the artifact. |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The ID of the artifact that was added. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Upsert a vector into the Marqo index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector |
list[float]
|
The vector to be indexed. |
required |
vector_id |
Optional[str]
|
The ID for the vector. If None, Marqo will generate an ID. |
None
|
namespace |
Optional[str]
|
An optional namespace for the vector. |
None
|
meta |
Optional[dict]
|
An optional dictionary of metadata for the vector. |
None
|
Raises:
Type | Description |
---|---|
Exception
|
This function is not yet implemented. |
Returns:
Type | Description |
---|---|
str
|
The ID of the vector that was added. |
Source code in griptape/drivers/vector/marqo_vector_store_driver.py
MongoDbAtlasVectorStoreDriver
Bases: BaseVectorStoreDriver
A Vector Store Driver for MongoDb Atlas.
Attributes:
Name | Type | Description |
---|---|---|
connection_string |
str
|
The connection string for the MongoDb Atlas cluster. |
database_name |
str
|
The name of the database to use. |
collection_name |
str
|
The name of the collection to use. |
index_name |
str
|
The name of the index to use. |
vector_path |
str
|
The path to the vector field in the collection. |
client |
MongoClient
|
An optional MongoDb client to use. Defaults to a new client using the connection string. |
Source code in griptape/drivers/vector/mongodb_atlas_vector_store_driver.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
MAX_NUM_CANDIDATES = 10000
class-attribute
instance-attribute
client: MongoClient = field(default=Factory(lambda self: import_optional_dependency('pymongo').MongoClient(self.connection_string), takes_self=True))
class-attribute
instance-attribute
collection_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
connection_string: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
database_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
index_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
num_candidates_multiplier: int = field(default=10, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
vector_path: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
delete_vector(vector_id)
get_collection()
Returns the MongoDB Collection instance for the specified database and collection name.
load_entries(namespace=None)
Loads all document entries from the MongoDB collection.
Entries can optionally be filtered by namespace.
Source code in griptape/drivers/vector/mongodb_atlas_vector_store_driver.py
load_entry(vector_id, namespace=None)
Loads a document entry from the MongoDB collection based on the vector ID.
Returns:
Type | Description |
---|---|
Optional[Entry]
|
The loaded Entry if found; otherwise, None is returned. |
Source code in griptape/drivers/vector/mongodb_atlas_vector_store_driver.py
query(query, count=None, namespace=None, include_vectors=False, offset=None, **kwargs)
Queries the MongoDB collection for documents that match the provided query string.
Results can be customized based on parameters like count, namespace, inclusion of vectors, offset, and index.
Source code in griptape/drivers/vector/mongodb_atlas_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Inserts or updates a vector in the collection.
If a vector with the given vector ID already exists, it is updated; otherwise, a new vector is inserted.
Source code in griptape/drivers/vector/mongodb_atlas_vector_store_driver.py
OpenAiChatPromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
base_url |
Optional[str]
|
An optional OpenAi API URL. |
api_key |
Optional[str]
|
An optional OpenAi API key. If not provided, the |
organization |
Optional[str]
|
An optional OpenAI organization. If not provided, the |
client |
OpenAI
|
An |
model |
str
|
An OpenAI model name. |
tokenizer |
BaseTokenizer
|
An |
user |
str
|
A user id. Can be used to track requests by user. |
response_format |
Optional[Literal['json_object']]
|
An optional OpenAi Chat Completion response format. Currently only supports |
seed |
Optional[int]
|
An optional OpenAi Chat Completion seed. |
ignored_exception_types |
tuple[type[Exception], ...]
|
An optional tuple of exception types to ignore. Defaults to OpenAI's known exception types. |
_ratelimit_request_limit |
Optional[int]
|
The maximum number of requests allowed in the current rate limit window. |
_ratelimit_requests_remaining |
Optional[int]
|
The number of requests remaining in the current rate limit window. |
_ratelimit_requests_reset_at |
Optional[datetime]
|
The time at which the current rate limit window resets. |
_ratelimit_token_limit |
Optional[int]
|
The maximum number of tokens allowed in the current rate limit window. |
_ratelimit_tokens_remaining |
Optional[int]
|
The number of tokens remaining in the current rate limit window. |
_ratelimit_tokens_reset_at |
Optional[datetime]
|
The time at which the current rate limit window resets. |
Source code in griptape/drivers/prompt/openai_chat_prompt_driver.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
base_url: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.OpenAI = field(default=Factory(lambda self: openai.OpenAI(api_key=self.api_key, base_url=self.base_url, organization=self.organization), takes_self=True))
class-attribute
instance-attribute
ignored_exception_types: tuple[type[Exception], ...] = field(default=Factory(lambda: (openai.BadRequestError, openai.AuthenticationError, openai.PermissionDeniedError, openai.NotFoundError, openai.ConflictError, openai.UnprocessableEntityError)), kw_only=True)
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
organization: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
response_format: Optional[Literal['json_object']] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
seed: Optional[int] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: BaseTokenizer = field(default=Factory(lambda self: OpenAiTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
user: str = field(default='', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__to_openai_role(prompt_input)
token_count(prompt_stack)
Source code in griptape/drivers/prompt/openai_chat_prompt_driver.py
try_run(prompt_stack)
Source code in griptape/drivers/prompt/openai_chat_prompt_driver.py
try_stream(prompt_stack)
Source code in griptape/drivers/prompt/openai_chat_prompt_driver.py
OpenAiCompletionPromptDriver
Bases: BasePromptDriver
Attributes:
Name | Type | Description |
---|---|---|
base_url |
Optional[str]
|
An optional OpenAi API URL. |
api_key |
Optional[str]
|
An optional OpenAi API key. If not provided, the |
organization |
Optional[str]
|
An optional OpenAI organization. If not provided, the |
client |
OpenAI
|
An |
model |
str
|
An OpenAI model name. |
tokenizer |
OpenAiTokenizer
|
An |
user |
str
|
A user id. Can be used to track requests by user. |
ignored_exception_types |
tuple[type[Exception], ...]
|
An optional tuple of exception types to ignore. Defaults to OpenAI's known exception types. |
Source code in griptape/drivers/prompt/openai_completion_prompt_driver.py
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
base_url: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.OpenAI = field(default=Factory(lambda self: openai.OpenAI(api_key=self.api_key, base_url=self.base_url, organization=self.organization), takes_self=True))
class-attribute
instance-attribute
ignored_exception_types: tuple[type[Exception], ...] = field(default=Factory(lambda: (openai.BadRequestError, openai.AuthenticationError, openai.PermissionDeniedError, openai.NotFoundError, openai.ConflictError, openai.UnprocessableEntityError)), kw_only=True)
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
organization: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: OpenAiTokenizer = field(default=Factory(lambda self: OpenAiTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
user: str = field(default='', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_run(prompt_stack)
Source code in griptape/drivers/prompt/openai_completion_prompt_driver.py
try_stream(prompt_stack)
Source code in griptape/drivers/prompt/openai_completion_prompt_driver.py
OpenAiEmbeddingDriver
Bases: BaseEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
OpenAI embedding model name. Defaults to |
base_url |
Optional[str]
|
API URL. Defaults to OpenAI's v1 API URL. |
api_key |
Optional[str]
|
API key to pass directly. Defaults to |
organization |
Optional[str]
|
OpenAI organization. Defaults to 'OPENAI_ORGANIZATION' environment variable. |
tokenizer |
OpenAiTokenizer
|
Optionally provide custom |
client |
OpenAI
|
Optionally provide custom |
azure_deployment |
OpenAI
|
An Azure OpenAi deployment id. |
azure_endpoint |
OpenAI
|
An Azure OpenAi endpoint. |
azure_ad_token |
OpenAI
|
An optional Azure Active Directory token. |
azure_ad_token_provider |
OpenAI
|
An optional Azure Active Directory token provider. |
api_version |
OpenAI
|
An Azure OpenAi API version. |
Source code in griptape/drivers/embedding/openai_embedding_driver.py
DEFAULT_MODEL = 'text-embedding-3-small'
class-attribute
instance-attribute
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
base_url: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.OpenAI = field(default=Factory(lambda self: openai.OpenAI(api_key=self.api_key, base_url=self.base_url, organization=self.organization), takes_self=True))
class-attribute
instance-attribute
model: str = field(default=DEFAULT_MODEL, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
organization: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: OpenAiTokenizer = field(default=Factory(lambda self: OpenAiTokenizer(model=self.model), takes_self=True), kw_only=True)
class-attribute
instance-attribute
try_embed_chunk(chunk)
Source code in griptape/drivers/embedding/openai_embedding_driver.py
OpenAiImageGenerationDriver
Bases: BaseImageGenerationDriver
Driver for the OpenAI image generation API.
Attributes:
Name | Type | Description |
---|---|---|
model |
OpenAI model, for example 'dall-e-2' or 'dall-e-3'. |
|
api_type |
str
|
OpenAI API type, for example 'open_ai' or 'azure'. |
api_version |
Optional[str]
|
API version. |
base_url |
Optional[str]
|
API URL. |
api_key |
Optional[str]
|
OpenAI API key. |
organization |
Optional[str]
|
OpenAI organization ID. |
style |
Optional[str]
|
Optional and only supported for dall-e-3, can be either 'vivid' or 'natural'. |
quality |
Union[Literal['standard'], Literal['hd']]
|
Optional and only supported for dall-e-3. Accepts 'standard', 'hd'. |
image_size |
Union[Literal['256x256'], Literal['512x512'], Literal['1024x1024'], Literal['1024x1792'], Literal['1792x1024']]
|
Size of the generated image. Must be one of the following, depending on the requested model: dall-e-2: [256x256, 512x512, 1024x1024] dall-e-3: [1024x1024, 1024x1792, 1792x1024] |
response_format |
Literal['b64_json']
|
The response format. Currently only supports 'b64_json' which will return a base64 encoded image in a JSON object. |
Source code in griptape/drivers/image_generation/openai_image_generation_driver.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
api_type: str = field(default=openai.api_type, kw_only=True)
class-attribute
instance-attribute
api_version: Optional[str] = field(default=openai.api_version, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
base_url: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.OpenAI = field(default=Factory(lambda self: openai.OpenAI(api_key=self.api_key, base_url=self.base_url, organization=self.organization), takes_self=True))
class-attribute
instance-attribute
image_size: Union[Literal['256x256'], Literal['512x512'], Literal['1024x1024'], Literal['1024x1792'], Literal['1792x1024']] = field(default='1024x1024', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
organization: Optional[str] = field(default=openai.organization, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
quality: Union[Literal['standard'], Literal['hd']] = field(default='standard', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
response_format: Literal['b64_json'] = field(default='b64_json', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
style: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_image_inpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/openai_image_generation_driver.py
try_image_outpainting(prompts, image, mask, negative_prompts=None)
Source code in griptape/drivers/image_generation/openai_image_generation_driver.py
try_image_variation(prompts, image, negative_prompts=None)
Source code in griptape/drivers/image_generation/openai_image_generation_driver.py
try_text_to_image(prompts, negative_prompts=None)
Source code in griptape/drivers/image_generation/openai_image_generation_driver.py
OpenAiVisionImageQueryDriver
Bases: BaseImageQueryDriver
Source code in griptape/drivers/image_query/openai_vision_image_query_driver.py
api_key: Optional[str] = field(default=None, kw_only=True)
class-attribute
instance-attribute
api_type: str = field(default=openai.api_type, kw_only=True)
class-attribute
instance-attribute
api_version: Optional[str] = field(default=openai.api_version, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
base_url: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
client: openai.OpenAI = field(default=Factory(lambda self: openai.OpenAI(api_key=self.api_key, base_url=self.base_url, organization=self.organization), takes_self=True))
class-attribute
instance-attribute
image_quality: Literal['auto', 'low', 'high'] = field(default='auto', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
organization: Optional[str] = field(default=openai.organization, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
try_query(query, images)
Source code in griptape/drivers/image_query/openai_vision_image_query_driver.py
OpenSearchVectorStoreDriver
Bases: BaseVectorStoreDriver
A Vector Store Driver for OpenSearch.
Attributes:
Name | Type | Description |
---|---|---|
host |
str
|
The host of the OpenSearch cluster. |
port |
int
|
The port of the OpenSearch cluster. |
http_auth |
str | tuple[str, Optional[str]]
|
The HTTP authentication credentials to use. |
use_ssl |
bool
|
Whether to use SSL. |
verify_certs |
bool
|
Whether to verify SSL certificates. |
index_name |
str
|
The name of the index to use. |
Source code in griptape/drivers/vector/opensearch_vector_store_driver.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
client: OpenSearch = field(default=Factory(lambda self: import_optional_dependency('opensearchpy').OpenSearch(hosts=[{'host': self.host, 'port': self.port}], http_auth=self.http_auth, use_ssl=self.use_ssl, verify_certs=self.verify_certs, connection_class=import_optional_dependency('opensearchpy').RequestsHttpConnection), takes_self=True))
class-attribute
instance-attribute
host: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
http_auth: str | tuple[str, Optional[str]] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
index_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
port: int = field(default=443, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
use_ssl: bool = field(default=True, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
verify_certs: bool = field(default=True, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
delete_vector(vector_id)
load_entries(namespace=None)
Retrieves all vector entries from OpenSearch that match the optional namespace.
Returns:
Type | Description |
---|---|
list[Entry]
|
A list of BaseVectorStoreDriver.Entry objects. |
Source code in griptape/drivers/vector/opensearch_vector_store_driver.py
load_entry(vector_id, namespace=None)
Retrieves a specific vector entry from OpenSearch based on its identifier and optional namespace.
Returns:
Type | Description |
---|---|
Optional[Entry]
|
If the entry is found, it returns an instance of BaseVectorStoreDriver.Entry; otherwise, None is returned. |
Source code in griptape/drivers/vector/opensearch_vector_store_driver.py
query(query, count=None, namespace=None, include_vectors=False, include_metadata=True, field_name='vector', **kwargs)
Performs a nearest neighbor search on OpenSearch to find vectors similar to the provided query string.
Results can be limited using the count parameter and optionally filtered by a namespace.
Returns:
Type | Description |
---|---|
list[QueryResult]
|
A list of BaseVectorStoreDriver.QueryResult objects, each encapsulating the retrieved vector, its similarity score, metadata, and namespace. |
Source code in griptape/drivers/vector/opensearch_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Inserts or updates a vector in OpenSearch.
If a vector with the given vector ID already exists, it is updated; otherwise, a new vector is inserted. Metadata associated with the vector can also be provided.
Source code in griptape/drivers/vector/opensearch_vector_store_driver.py
PgVectorVectorStoreDriver
Bases: BaseVectorStoreDriver
A vector store driver to Postgres using the PGVector extension.
Attributes:
Name | Type | Description |
---|---|---|
connection_string |
Optional[str]
|
An optional string describing the target Postgres database instance. |
create_engine_params |
dict
|
Additional configuration params passed when creating the database connection. |
engine |
Optional[Engine]
|
An optional sqlalchemy Postgres engine to use. |
table_name |
str
|
Optionally specify the name of the table to used to store vectors. |
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
connection_string: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
create_engine_params: dict = field(factory=dict, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
engine: Optional[Engine] = field(default=None, kw_only=True)
class-attribute
instance-attribute
table_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__attrs_post_init__()
If an engine is provided, it will be used to connect to the database. If not, a connection string is used to create a new database connection here.
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
default_vector_model()
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
delete_vector(vector_id)
load_entries(namespace=None)
Retrieves all vector entries from the collection, optionally filtering to only those that match the provided namespace.
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
load_entry(vector_id, namespace=None)
Retrieves a specific vector entry from the collection based on its identifier and optional namespace.
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
query(query, count=BaseVectorStoreDriver.DEFAULT_QUERY_COUNT, namespace=None, include_vectors=False, distance_metric='cosine_distance', **kwargs)
Performs a search on the collection to find vectors similar to the provided input vector, optionally filtering to only those that match the provided namespace.
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
setup(create_schema=True, install_uuid_extension=True, install_vector_extension=True)
Provides a mechanism to initialize the database schema and extensions.
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Inserts or updates a vector in the collection.
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
validate_connection_string(_, connection_string)
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
validate_engine(_, engine)
Source code in griptape/drivers/vector/pgvector_vector_store_driver.py
PineconeVectorStoreDriver
Bases: BaseVectorStoreDriver
Source code in griptape/drivers/vector/pinecone_vector_store_driver.py
api_key: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
environment: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
index: pinecone.Index = field(init=False)
class-attribute
instance-attribute
index_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
project_name: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
__attrs_post_init__()
Source code in griptape/drivers/vector/pinecone_vector_store_driver.py
delete_vector(vector_id)
load_entries(namespace=None)
Source code in griptape/drivers/vector/pinecone_vector_store_driver.py
load_entry(vector_id, namespace=None)
Source code in griptape/drivers/vector/pinecone_vector_store_driver.py
query(query, count=None, namespace=None, include_vectors=False, include_metadata=True, **kwargs)
Source code in griptape/drivers/vector/pinecone_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Source code in griptape/drivers/vector/pinecone_vector_store_driver.py
RedisVectorStoreDriver
Bases: BaseVectorStoreDriver
A Vector Store Driver for Redis.
This driver interfaces with a Redis instance and utilizes the Redis hashes and RediSearch module to store, retrieve, and query vectors in a structured manner. Proper setup of the Redis instance and RediSearch is necessary for the driver to function correctly.
Attributes:
Name | Type | Description |
---|---|---|
host |
str
|
The host of the Redis instance. |
port |
int
|
The port of the Redis instance. |
db |
int
|
The database of the Redis instance. |
password |
Optional[str]
|
The password of the Redis instance. |
index |
str
|
The name of the index to use. |
Source code in griptape/drivers/vector/redis_vector_store_driver.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
client: Redis = field(default=Factory(lambda self: import_optional_dependency('redis').Redis(host=self.host, port=self.port, db=self.db, password=self.password, decode_responses=False), takes_self=True))
class-attribute
instance-attribute
db: int = field(kw_only=True, default=0, metadata={'serializable': True})
class-attribute
instance-attribute
host: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
index: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
password: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
port: int = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
delete_vector(vector_id)
load_entries(namespace=None)
Retrieves all vector entries from Redis that match the optional namespace.
Returns:
Type | Description |
---|---|
list[Entry]
|
A list of |
Source code in griptape/drivers/vector/redis_vector_store_driver.py
load_entry(vector_id, namespace=None)
Retrieves a specific vector entry from Redis based on its identifier and optional namespace.
Returns:
Type | Description |
---|---|
Optional[Entry]
|
If the entry is found, it returns an instance of BaseVectorStoreDriver.Entry; otherwise, None is returned. |
Source code in griptape/drivers/vector/redis_vector_store_driver.py
query(query, count=None, namespace=None, include_vectors=False, **kwargs)
Performs a nearest neighbor search on Redis to find vectors similar to the provided input vector.
Results can be limited using the count parameter and optionally filtered by a namespace.
Returns:
Type | Description |
---|---|
list[QueryResult]
|
A list of BaseVectorStoreDriver.QueryResult objects, each encapsulating the retrieved vector, its similarity score, metadata, and namespace. |
Source code in griptape/drivers/vector/redis_vector_store_driver.py
upsert_vector(vector, vector_id=None, namespace=None, meta=None, **kwargs)
Inserts or updates a vector in Redis.
If a vector with the given vector ID already exists, it is updated; otherwise, a new vector is inserted. Metadata associated with the vector can also be provided.
Source code in griptape/drivers/vector/redis_vector_store_driver.py
SageMakerFalconPromptModelDriver
Bases: BasePromptModelDriver
Source code in griptape/drivers/prompt_model/sagemaker_falcon_prompt_model_driver.py
DEFAULT_MAX_TOKENS = 600
class-attribute
instance-attribute
tokenizer: HuggingFaceTokenizer
property
process_output(output)
Source code in griptape/drivers/prompt_model/sagemaker_falcon_prompt_model_driver.py
prompt_stack_to_model_input(prompt_stack)
prompt_stack_to_model_params(prompt_stack)
Source code in griptape/drivers/prompt_model/sagemaker_falcon_prompt_model_driver.py
SageMakerHuggingFaceEmbeddingModelDriver
Bases: BaseEmbeddingModelDriver
Source code in griptape/drivers/embedding_model/sagemaker_huggingface_embedding_model_driver.py
chunk_to_model_params(chunk)
SageMakerLlamaPromptModelDriver
Bases: BasePromptModelDriver
Source code in griptape/drivers/prompt_model/sagemaker_llama_prompt_model_driver.py
DEFAULT_MAX_TOKENS = 600
class-attribute
instance-attribute
tokenizer: HuggingFaceTokenizer
property
process_output(output)
Source code in griptape/drivers/prompt_model/sagemaker_llama_prompt_model_driver.py
prompt_stack_to_model_input(prompt_stack)
prompt_stack_to_model_params(prompt_stack)
Source code in griptape/drivers/prompt_model/sagemaker_llama_prompt_model_driver.py
SageMakerTensorFlowHubEmbeddingModelDriver
Bases: BaseEmbeddingModelDriver
Source code in griptape/drivers/embedding_model/sagemaker_tensorflow_hub_embedding_model_driver.py
chunk_to_model_params(chunk)
SnowflakeSqlDriver
Bases: BaseSqlDriver
Source code in griptape/drivers/sql/snowflake_sql_driver.py
connection_func: Callable[[], SnowflakeConnection] = field(kw_only=True)
class-attribute
instance-attribute
engine: Engine = field(default=Factory(lambda self: import_optional_dependency('sqlalchemy').create_engine('snowflake://not@used/db', creator=self.connection_func), takes_self=True), kw_only=True)
class-attribute
instance-attribute
execute_query(query)
execute_query_raw(query)
Source code in griptape/drivers/sql/snowflake_sql_driver.py
get_table_schema(table_name, schema=None)
Source code in griptape/drivers/sql/snowflake_sql_driver.py
validate_connection_func(_, connection_func)
Source code in griptape/drivers/sql/snowflake_sql_driver.py
validate_engine_url(_, engine)
SqlDriver
Bases: BaseSqlDriver
Source code in griptape/drivers/sql/sql_driver.py
create_engine_params: dict = field(factory=dict, kw_only=True)
class-attribute
instance-attribute
engine: Engine = field(init=False)
class-attribute
instance-attribute
engine_url: str = field(kw_only=True)
class-attribute
instance-attribute
__attrs_post_init__()
execute_query(query)
execute_query_raw(query)
Source code in griptape/drivers/sql/sql_driver.py
get_table_schema(table_name, schema=None)
Source code in griptape/drivers/sql/sql_driver.py
TrafilaturaWebScraperDriver
Bases: BaseWebScraperDriver
Source code in griptape/drivers/web_scraper/trafilatura_web_scraper_driver.py
include_links: bool = field(default=True, kw_only=True)
class-attribute
instance-attribute
scrape_url(url)
Source code in griptape/drivers/web_scraper/trafilatura_web_scraper_driver.py
VoyageAiEmbeddingDriver
Bases: BaseEmbeddingDriver
Attributes:
Name | Type | Description |
---|---|---|
model |
str
|
VoyageAI embedding model name. Defaults to |
api_key |
Optional[str]
|
API key to pass directly. Defaults to |
tokenizer |
VoyageAiTokenizer
|
Optionally provide custom |
client |
Any
|
Optionally provide custom VoyageAI |
input_type |
str
|
VoyageAI input type. Defaults to |
Source code in griptape/drivers/embedding/voyageai_embedding_driver.py
DEFAULT_MODEL = 'voyage-large-2'
class-attribute
instance-attribute
api_key: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
client: Any = field(default=Factory(lambda self: import_optional_dependency('voyageai').Client(api_key=self.api_key), takes_self=True))
class-attribute
instance-attribute
input_type: str = field(default='document', kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
model: str = field(default=DEFAULT_MODEL, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
tokenizer: VoyageAiTokenizer = field(default=Factory(lambda self: VoyageAiTokenizer(model=self.model, api_key=self.api_key), takes_self=True), kw_only=True)
class-attribute
instance-attribute
WebhookEventListenerDriver
Bases: BaseEventListenerDriver