Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): credential swap to api keys in cred store #8403

Merged
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9e1b0d5
feat(backend): credential swap
ntindle Oct 15, 2024
310e29b
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 23, 2024
6efb5e2
ci: formatting
ntindle Oct 23, 2024
1018f92
fix: importing is hard okay
ntindle Oct 23, 2024
4d0590a
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 23, 2024
358e603
fix: spelln' is hard
ntindle Oct 23, 2024
95ee3b7
feat: better credential provider handling
ntindle Oct 23, 2024
3a6f2d3
docs: update the imports locations
ntindle Oct 23, 2024
4f6dab6
fix: test credentials + formatting
ntindle Oct 23, 2024
b1a7972
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 24, 2024
62bdf57
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 25, 2024
c3a0c0e
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 25, 2024
9d06fda
feat: drop continuous read mode
ntindle Oct 25, 2024
770f9a2
fix: lint
ntindle Oct 25, 2024
9602065
feat: fallback credentials
ntindle Oct 25, 2024
4040393
feat: charge for credential useage and have a bad backup mechnism
ntindle Oct 25, 2024
83d7e40
fix: don't save default credentials + add d_id
ntindle Oct 25, 2024
b6725b9
fix: formatting
ntindle Oct 25, 2024
5955d6e
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 28, 2024
edce210
feat: basic encryption/decryption
ntindle Oct 30, 2024
9748a67
ref: move files around
ntindle Oct 30, 2024
68bc951
ref: sign all blocks out of their credentials
ntindle Oct 30, 2024
76ee333
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
ntindle Oct 30, 2024
19e45d7
ref: update target to match a new, and encrypted future
ntindle Oct 30, 2024
a9d47d9
wip: llm provider merger
ntindle Oct 30, 2024
599f18c
don't delete `credentials` input on nodes
Pwuts Oct 30, 2024
3ce6ef4
fix llm block ci issues
Swiftyos Oct 30, 2024
1963bcf
updated get AICredentials
Swiftyos Oct 30, 2024
403cd51
fix fix
Swiftyos Oct 30, 2024
befcef5
insert migration to move integration credentials from `auth.user` met…
Pwuts Oct 30, 2024
c1ce72f
fixed migration
Swiftyos Oct 30, 2024
59d0a32
add migration for existing user integration credentials
Pwuts Oct 30, 2024
47d5263
disabled reddit and email block
Swiftyos Oct 30, 2024
2b1cc3b
fix credential handling in LLM blocks
Pwuts Oct 30, 2024
0bea2d4
add other secret fields to credential scrubber migration
Pwuts Oct 30, 2024
32fe80f
add other secret fields to credential scrubber migration (vol. 2)
Pwuts Oct 30, 2024
adb2436
fix: pr fixes
ntindle Oct 30, 2024
c1ef707
Merge branch 'dev' into ntindle/secrt-938-update-all-api-keys-in-bloc…
aarushik93 Oct 31, 2024
292a5ed
fix: mock funciton
ntindle Oct 31, 2024
b95368a
add encrypted values
aarushik93 Oct 31, 2024
5e339f9
feat: add .env example
ntindle Oct 31, 2024
8aca620
Merge branch 'ntindle/secrt-938-update-all-api-keys-in-blocks-to-cred…
ntindle Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: don't save default credentials + add d_id
ntindle committed Oct 25, 2024
commit 83d7e40998e85d2420589c8c45470a65227e3724
Original file line number Diff line number Diff line change
@@ -66,6 +66,23 @@
title="Use Credits for Groq",
expires_at=None,
)
did_credentials = APIKeyCredentials(
id="7f7b0654-c36b-4565-8fa7-9a52575dfae2",
provider="d_id",
api_key=SecretStr(settings.secrets.did_api_key),
title="Use Credits for D-ID",
expires_at=None,
)

DEFAULT_CREDENTIALS = [
revid_credentials,
ideogram_credentials,
replicate_credentials,
openai_credentials,
anthropic_credentials,
groq_credentials,
did_credentials,
]


class SupabaseIntegrationCredentialsStore:
@@ -108,6 +125,8 @@ def get_all_creds(self, user_id: str) -> list[Credentials]:
all_credentials.append(openai_credentials)
if settings.secrets.anthropic_api_key:
all_credentials.append(anthropic_credentials)
if settings.secrets.did_api_key:
all_credentials.append(did_credentials)
return all_credentials

def get_creds_by_id(self, user_id: str, credentials_id: str) -> Credentials | None:
@@ -246,6 +265,8 @@ def _set_user_integration_creds(
self, user_id: str, credentials: list[Credentials]
) -> None:
raw_metadata = self._get_user_metadata(user_id)
# Remove default credentials from the list
credentials = [c for c in credentials if c not in DEFAULT_CREDENTIALS]
raw_metadata.integration_credentials = [c.model_dump() for c in credentials]
self.db_manager.update_user_metadata(user_id, raw_metadata)

26 changes: 24 additions & 2 deletions autogpt_platform/backend/backend/data/credit.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
from typing import Any, Optional, Type

from backend.blocks.ai_shortform_video_block import AIShortformVideoCreatorBlock
from backend.blocks.google.gmail import GmailListLabelsBlock
from backend.blocks.ideogram import IdeogramModelBlock
from backend.blocks.replicate_flux_advanced import ReplicateFluxAdvancedModelBlock
import prisma.errors
from prisma import Json
@@ -31,6 +31,7 @@
groq_credentials,
openai_credentials,
anthropic_credentials,
did_credentials,
)


@@ -131,12 +132,33 @@ def __init__(
AIStructuredResponseGeneratorBlock: llm_cost,
AITextSummarizerBlock: llm_cost,
CreateTalkingAvatarVideoBlock: [
BlockCost(cost_amount=15, cost_filter={"api_key": None})
BlockCost(
cost_amount=15,
cost_filter={
"credentials": {
"id": did_credentials.id,
"provider": did_credentials.provider,
"type": did_credentials.type,
}
},
)
],
SearchTheWebBlock: [BlockCost(cost_amount=1)],
ExtractWebsiteContentBlock: [
BlockCost(cost_amount=1, cost_filter={"raw_content": False})
],
IdeogramModelBlock: [
BlockCost(
cost_amount=1,
cost_filter={
"credentials": {
"id": ideogram_credentials.id,
"provider": ideogram_credentials.provider,
"type": ideogram_credentials.type,
}
},
)
],
AIShortformVideoCreatorBlock: [
BlockCost(
cost_amount=10,