mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-25 05:25:37 -04:00
5b74c3a1de
* feat: Complete CometAPI model provider plugin with 500+ AI models support - Add CometAPI model provider with comprehensive API integration - Support for LLM, text embedding, TTS, and speech-to-text models - Include multilingual descriptions (EN/JP/ZH/PT-BR) - Add proper plugin structure with manifest, provider configs, and assets - Implement common OpenAI-compatible interface for model integration * feature: Better multi-language support * fix: update author name from 'cometapi' to 'langgenius' in manifest files --------- Co-authored-by: NoahCode <51156988+NoahCodeGG@users.noreply.github.com>
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
import logging
|
|
from dify_plugin.entities.model import ModelType
|
|
from dify_plugin.errors.model import CredentialsValidateFailedError
|
|
from dify_plugin import ModelProvider
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class CometapiProvider(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)
|
|
|
|
# Use `gpt-4.1-nano` model for validate,
|
|
# no matter what model you pass in, text completion model or chat model
|
|
model_instance.validate_credentials(
|
|
model="gpt-4.1-nano", 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 |