Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
test_provider.py29 linesDownload Raw Back to mixedbread
1import os2from unittest.mock import Mock, patch3 4import pytest5 6from core.model_runtime.errors.validate import CredentialsValidateFailedError7from core.model_runtime.model_providers.mixedbread.mixedbread import MixedBreadProvider8 9 10def test_validate_provider_credentials():11    provider = MixedBreadProvider()12 13    with pytest.raises(CredentialsValidateFailedError):14        provider.validate_provider_credentials(credentials={"api_key": "hahahaha"})15    with patch("requests.post") as mock_post:16        mock_response = Mock()17        mock_response.json.return_value = {18            "usage": {"prompt_tokens": 3, "total_tokens": 3},19            "model": "mixedbread-ai/mxbai-embed-large-v1",20            "data": [{"embedding": [0.23333 for _ in range(1024)], "index": 0, "object": "embedding"}],21            "object": "list",22            "normalized": "true",23            "encoding_format": "float",24            "dimensions": 1024,25        }26        mock_response.status_code = 20027        mock_post.return_value = mock_response28        provider.validate_provider_credentials(credentials={"api_key": os.environ.get("MIXEDBREAD_API_KEY")})29