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

Feature/sambanovacloud integration dify #11918

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Next Next commit
sambanova cloud integration - provider
  • Loading branch information
snova-rodrigom committed Dec 20, 2024
commit e0e5fe9bbad91aba5ec805fa4d8b333c91ddcce9
Empty file.
26 changes: 26 additions & 0 deletions api/core/model_runtime/model_providers/sambanova/sambanova.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import logging

from core.model_runtime.entities.model_entities import ModelType
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.__base.model_provider import ModelProvider

logger = logging.getLogger(__name__)


class SambanovaProvider(ModelProvider):
def validate_provider_credentials(self, credentials: dict) -> None:
"""
Validate provider credentials

if validate failed, raise exception

:param credentials: provider credentials, credentials form defined in `provider_credential_schema`.
"""
try:
model_instance = self.get_model_instance(ModelType.LLM)
model_instance.validate_credentials(model="Meta-Llama-3.1-8B-Instruct", credentials=credentials)
except CredentialsValidateFailedError as ex:
raise ex
except Exception as ex:
logger.exception(f"{self.get_provider_schema().provider} credentials validate failed")
raise ex
28 changes: 28 additions & 0 deletions api/core/model_runtime/model_providers/sambanova/sambanova.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
provider: sambanova
label:
en_US: Sambanova
description:
en_US: SambaNova Cloud
icon_small:
en_US: icon_s_en.png
icon_large:
en_US: icon_l_en.png
background: "#F0F0EB"
help:
title:
en_US: Get your API Key from SambaNova Cloud
url:
en_US: https://cloud.sambanova.ai/apis
supported_model_types:
- llm
configurate_methods:
- predefined-model
provider_credential_schema:
credential_form_schemas:
- variable: sambanova_api_key
label:
en_US: API Key
type: secret-input
required: true
placeholder:
en_US: Enter your API Key