您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

huggingface.py 541B

1234567891011121314151617181920
  1. import os
  2. import pytest
  3. from _pytest.monkeypatch import MonkeyPatch
  4. from huggingface_hub import InferenceClient # type: ignore
  5. from tests.integration_tests.model_runtime.__mock.huggingface_chat import MockHuggingfaceChatClass
  6. MOCK = os.getenv("MOCK_SWITCH", "false").lower() == "true"
  7. @pytest.fixture
  8. def setup_huggingface_mock(request, monkeypatch: MonkeyPatch):
  9. if MOCK:
  10. monkeypatch.setattr(InferenceClient, "text_generation", MockHuggingfaceChatClass.text_generation)
  11. yield
  12. if MOCK:
  13. monkeypatch.undo()