feat/enhance the multi-modal support (#8818)

This commit is contained in:
-LAN-
2024-10-21 10:43:49 +08:00
committed by GitHub
parent 7a1d6fe509
commit e61752bd3a
267 changed files with 6263 additions and 3523 deletions

View File

@@ -6,6 +6,8 @@ import httpx
import pytest
from _pytest.monkeypatch import MonkeyPatch
from core.helper import ssrf_proxy
MOCK = os.getenv("MOCK_SWITCH", "false") == "true"
@@ -24,10 +26,16 @@ class MockedHttp:
# get data, files
data = kwargs.get("data")
files = kwargs.get("files")
json = kwargs.get("json")
content = kwargs.get("content")
if data is not None:
resp = dumps(data).encode("utf-8")
elif files is not None:
resp = dumps(files).encode("utf-8")
elif json is not None:
resp = dumps(json).encode("utf-8")
elif content is not None:
resp = content
else:
resp = b"OK"
@@ -43,6 +51,6 @@ def setup_http_mock(request, monkeypatch: MonkeyPatch):
yield
return
monkeypatch.setattr(httpx, "request", MockedHttp.httpx_request)
monkeypatch.setattr(ssrf_proxy, "make_request", MockedHttp.httpx_request)
yield
monkeypatch.undo()