Download api/tests/integration_tests/model_runtime/__mock/huggingface.py from ZHZ1024/dify: direct link, hf CLI and curl.
- Browser
- Download file 525 Bytes
-
https://huggingface.co/spaces/ZHZ1024/dify/resolve/main/api/tests/integration_tests/model_runtime/__mock/huggingface.py
- Command line
-
hf download hf://spaces/ZHZ1024/dify/api/tests/integration_tests/model_runtime/__mock/huggingface.py
-
curl -L -o huggingface.py https://huggingface.co/spaces/ZHZ1024/dify/resolve/main/api/tests/integration_tests/model_runtime/__mock/huggingface.py
525 Bytes
| import os | |
| import pytest | |
| from _pytest.monkeypatch import MonkeyPatch | |
| from huggingface_hub import InferenceClient | |
| from tests.integration_tests.model_runtime.__mock.huggingface_chat import MockHuggingfaceChatClass | |
| MOCK = os.getenv("MOCK_SWITCH", "false").lower() == "true" | |
| def setup_huggingface_mock(request, monkeypatch: MonkeyPatch): | |
| if MOCK: | |
| monkeypatch.setattr(InferenceClient, "text_generation", MockHuggingfaceChatClass.text_generation) | |
| yield | |
| if MOCK: | |
| monkeypatch.undo() | |