From e6e47373ac8e263d958df4673ad3cb21fe936007 Mon Sep 17 00:00:00 2001 From: Aarushi <50577581+aarushik93@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:18:53 -0600 Subject: [PATCH] feat(blocks/jina): Add default credentials for Jina (#8603) add jina defaults --- .../store.py | 11 +++++++++++ autogpt_platform/backend/backend/data/credit.py | 14 +++++++++++++- autogpt_platform/backend/backend/util/settings.py | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/autogpt_libs/autogpt_libs/supabase_integration_credentials_store/store.py b/autogpt_platform/autogpt_libs/autogpt_libs/supabase_integration_credentials_store/store.py index e84b375c58bc..02507009abae 100644 --- a/autogpt_platform/autogpt_libs/autogpt_libs/supabase_integration_credentials_store/store.py +++ b/autogpt_platform/autogpt_libs/autogpt_libs/supabase_integration_credentials_store/store.py @@ -72,6 +72,14 @@ title="Use Credits for D-ID", expires_at=None, ) +jina_credentials = APIKeyCredentials( + id="7f26de70-ba0d-494e-ba76-238e65e7b45f", + provider="jina", + api_key=SecretStr(settings.secrets.jina_api_key), + title="Use Credits for Jina", + expires_at=None, +) + DEFAULT_CREDENTIALS = [ revid_credentials, @@ -81,6 +89,7 @@ anthropic_credentials, groq_credentials, did_credentials, + jina_credentials, ] @@ -124,6 +133,8 @@ def get_all_creds(self, user_id: str) -> list[Credentials]: all_credentials.append(anthropic_credentials) if settings.secrets.did_api_key: all_credentials.append(did_credentials) + if settings.secrets.jina_api_key: + all_credentials.append(jina_credentials) return all_credentials def get_creds_by_id(self, user_id: str, credentials_id: str) -> Credentials | None: diff --git a/autogpt_platform/backend/backend/data/credit.py b/autogpt_platform/backend/backend/data/credit.py index 2323d38280e1..d3618e658b7e 100644 --- a/autogpt_platform/backend/backend/data/credit.py +++ b/autogpt_platform/backend/backend/data/credit.py @@ -9,6 +9,7 @@ did_credentials, groq_credentials, ideogram_credentials, + jina_credentials, openai_credentials, replicate_credentials, revid_credentials, @@ -144,7 +145,18 @@ def __init__( }, ) ], - SearchTheWebBlock: [BlockCost(cost_amount=1)], + SearchTheWebBlock: [ + BlockCost( + cost_amount=1, + cost_filter={ + "credentials": { + "id": jina_credentials.id, + "provider": jina_credentials.provider, + "type": jina_credentials.type, + } + }, + ) + ], ExtractWebsiteContentBlock: [ BlockCost(cost_amount=1, cost_filter={"raw_content": False}) ], diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py index 426f12316ec5..07b3739dd43a 100644 --- a/autogpt_platform/backend/backend/util/settings.py +++ b/autogpt_platform/backend/backend/util/settings.py @@ -266,6 +266,7 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings): replicate_api_key: str = Field(default="", description="Replicate API Key") unreal_speech_api_key: str = Field(default="", description="Unreal Speech API Key") ideogram_api_key: str = Field(default="", description="Ideogram API Key") + jina_api_key: str = Field(default="", description="Jina API Key") # Add more secret fields as needed