tweak(backend): Update all block costs (#8639)

* Add support for default credentials to unreal block

* Refactor block cost configuration and add new blocks

This commit refactors the block cost configuration file and adds support for new blocks. The changes include:
- Importing the `AIMusicGeneratorBlock`, `JinaEmbeddingBlock`, and `UnrealTextToSpeechBlock` classes
- Updating the `BLOCK_COSTS` dictionary to include costs for the new blocks

These changes enable the usage of the newly introduced blocks.
This commit is contained in:
Toran Bruce Richards
2024-11-13 16:05:32 +00:00
committed by GitHub
parent ef3f7aad18
commit aafc101224
3 changed files with 55 additions and 2 deletions

View File

@@ -79,6 +79,13 @@ jina_credentials = APIKeyCredentials(
title="Use Credits for Jina",
expires_at=None,
)
unreal_credentials = APIKeyCredentials(#
id="66f20754-1b81-48e4-91d0-f4f0dd82145f",
provider="unreal",
api_key=SecretStr(settings.secrets.unreal_speech_api_key),
title="Use Credits for Unreal",
expires_at=None,
)
DEFAULT_CREDENTIALS = [
@@ -90,6 +97,7 @@ DEFAULT_CREDENTIALS = [
groq_credentials,
did_credentials,
jina_credentials,
unreal_credentials,
]
@@ -135,6 +143,8 @@ class SupabaseIntegrationCredentialsStore:
all_credentials.append(did_credentials)
if settings.secrets.jina_api_key:
all_credentials.append(jina_credentials)
if settings.secrets.unreal_speech_api_key:
all_credentials.append(unreal_credentials)
return all_credentials
def get_creds_by_id(self, user_id: str, credentials_id: str) -> Credentials | None:

View File

@@ -9,14 +9,18 @@ from autogpt_libs.supabase_integration_credentials_store.store import (
openai_credentials,
replicate_credentials,
revid_credentials,
unreal_credentials,
)
from backend.blocks.ai_music_generator import AIMusicGeneratorBlock
from backend.blocks.ai_shortform_video_block import AIShortformVideoCreatorBlock
from backend.blocks.ideogram import IdeogramModelBlock
from backend.blocks.jina.embeddings import JinaEmbeddingBlock
from backend.blocks.jina.search import SearchTheWebBlock
from backend.blocks.llm import (
MODEL_METADATA,
AIConversationBlock,
AIListGeneratorBlock,
AIStructuredResponseGeneratorBlock,
AITextGeneratorBlock,
AITextSummarizerBlock,
@@ -25,6 +29,7 @@ from backend.blocks.llm import (
from backend.blocks.replicate_flux_advanced import ReplicateFluxAdvancedModelBlock
from backend.blocks.search import ExtractWebsiteContentBlock
from backend.blocks.talking_head import CreateTalkingAvatarVideoBlock
from backend.blocks.text_to_speech_block import UnrealTextToSpeechBlock
from backend.data.block import Block
from backend.data.cost import BlockCost, BlockCostType
@@ -128,6 +133,7 @@ BLOCK_COSTS: dict[Type[Block], list[BlockCost]] = {
AITextGeneratorBlock: LLM_COST,
AIStructuredResponseGeneratorBlock: LLM_COST,
AITextSummarizerBlock: LLM_COST,
AIListGeneratorBlock: LLM_COST,
CreateTalkingAvatarVideoBlock: [
BlockCost(
cost_amount=15,
@@ -157,7 +163,7 @@ BLOCK_COSTS: dict[Type[Block], list[BlockCost]] = {
],
IdeogramModelBlock: [
BlockCost(
cost_amount=1,
cost_amount=16,
cost_filter={
"credentials": {
"id": ideogram_credentials.id,
@@ -169,7 +175,7 @@ BLOCK_COSTS: dict[Type[Block], list[BlockCost]] = {
],
AIShortformVideoCreatorBlock: [
BlockCost(
cost_amount=10,
cost_amount=50,
cost_filter={
"credentials": {
"id": revid_credentials.id,
@@ -191,4 +197,40 @@ BLOCK_COSTS: dict[Type[Block], list[BlockCost]] = {
},
)
],
AIMusicGeneratorBlock: [
BlockCost(
cost_amount=11,
cost_filter={
"credentials": {
"id": replicate_credentials.id,
"provider": replicate_credentials.provider,
"type": replicate_credentials.type,
}
},
)
],
JinaEmbeddingBlock: [
BlockCost(
cost_amount=12,
cost_filter={
"credentials": {
"id": jina_credentials.id,
"provider": jina_credentials.provider,
"type": jina_credentials.type,
}
},
)
],
UnrealTextToSpeechBlock: [
BlockCost(
cost_amount=5,
cost_filter={
"credentials": {
"id": unreal_credentials.id,
"provider": unreal_credentials.provider,
"type": unreal_credentials.type,
}
},
)
],
}

View File

@@ -267,6 +267,7 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):
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")
unreal_speech_api_key: str = Field(default="", description="Unreal Speech API Key")
# Add more secret fields as needed