From 9470a9e202fce9b997b17af0ad6f1dcb9a2e39ce Mon Sep 17 00:00:00 2001 From: Aarushi Date: Wed, 23 Oct 2024 19:36:23 +0100 Subject: [PATCH] update pincone credentials provider --- .../backend/backend/blocks/pinecone.py | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/autogpt_platform/backend/backend/blocks/pinecone.py b/autogpt_platform/backend/backend/blocks/pinecone.py index c3e008e1b043..5963e75266bd 100644 --- a/autogpt_platform/backend/backend/blocks/pinecone.py +++ b/autogpt_platform/backend/backend/blocks/pinecone.py @@ -6,17 +6,27 @@ from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema from backend.data.model import CredentialsField, CredentialsMetaInput, SchemaField +PineconeCredentials = APIKeyCredentials +PineconeCredentialsInput = CredentialsMetaInput[ + Literal["pinecone"], + Literal["api_key"], +] + + +def PineconeCredentialsField() -> PineconeCredentialsInput: + """ + Creates a Pinecone credentials input on a block. + + """ + return CredentialsField( + provider="pinecone", + supported_credential_types={"api_key"}, + description="The Pinecone integration can be used with an API Key.", + ) class PineconeInitBlock(Block): class Input(BlockSchema): - credentials: CredentialsMetaInput[Literal["pinecone"], Literal["api_key"]] = ( - CredentialsField( - provider="pinecone", - supported_credential_types={"api_key"}, - description="The Pinecone integration can be used with " - "any API key with sufficient permissions for the blocks it is used on.", - ) - ) + credentials: PineconeCredentialsInput = PineconeCredentialsField() index_name: str = SchemaField(description="Name of the Pinecone index") dimension: int = SchemaField( description="Dimension of the vectors", default=768 @@ -72,14 +82,7 @@ def run( class PineconeQueryBlock(Block): class Input(BlockSchema): - credentials: CredentialsMetaInput[Literal["pinecone"], Literal["api_key"]] = ( - CredentialsField( - provider="pinecone", - supported_credential_types={"api_key"}, - description="The Pinecone integration can be used with " - "any API key with sufficient permissions for the blocks it is used on.", - ) - ) + credentials: PineconeCredentialsInput = PineconeCredentialsField() query_vector: list = SchemaField(description="Query vector") namespace: str = SchemaField( description="Namespace to query in Pinecone", default=""