add openai api call switch; fix ocr

This commit is contained in:
yzlin 2024-01-05 14:34:44 +08:00
parent ab04f610a3
commit 1249d12b6f
4 changed files with 30 additions and 22 deletions

View file

@ -23,6 +23,8 @@ from metagpt.utils.git_repository import GitRepository
from tests.mock.mock_llm import MockLLM
RSP_CACHE_NEW = {} # used globally for producing new and useful only response cache
ALLOW_OPENAI_API_CALL = os.environ.get("ALLOW_OPENAI_API_CALL", False)
ALLOW_OPENAI_API_CALL = True
@pytest.fixture(scope="session")
@ -53,7 +55,7 @@ def pytest_runtest_makereport(item, call):
@pytest.fixture(scope="function", autouse=True)
def llm_mock(rsp_cache, mocker, request):
llm = MockLLM()
llm = MockLLM(allow_open_api_call=ALLOW_OPENAI_API_CALL)
llm.rsp_cache = rsp_cache
mocker.patch("metagpt.provider.base_llm.BaseLLM.aask", llm.aask)
mocker.patch("metagpt.provider.base_llm.BaseLLM.aask_batch", llm.aask_batch)