add rsp_cache.json and some formatting

This commit is contained in:
yzlin 2024-01-03 10:58:22 +08:00
parent 9efb9e6e80
commit 075bd9f747
3 changed files with 85 additions and 7 deletions

View file

@ -7,19 +7,19 @@
"""
import asyncio
import logging
import re
import json
from typing import Optional
import logging
import os
import re
from typing import Optional
import pytest
from metagpt.config import CONFIG, Config
from metagpt.const import DEFAULT_WORKSPACE_ROOT, TEST_DATA_PATH
from metagpt.llm import LLM
from metagpt.provider.openai_api import OpenAILLM
from metagpt.logs import logger
from metagpt.provider.openai_api import OpenAILLM
from metagpt.utils.git_repository import GitRepository
@ -66,9 +66,9 @@ class MockLLM(OpenAILLM):
@pytest.fixture(scope="session")
def rsp_cache():
model_version = CONFIG.openai_api_model
rsp_cache_file_path = TEST_DATA_PATH / f"rsp_cache_{model_version}.json" # read repo-provided
new_rsp_cache_file_path = TEST_DATA_PATH / f"rsp_cache_new.json" # exporting a new copy
# model_version = CONFIG.openai_api_model
rsp_cache_file_path = TEST_DATA_PATH / "rsp_cache.json" # read repo-provided
new_rsp_cache_file_path = TEST_DATA_PATH / "rsp_cache_new.json" # exporting a new copy
if os.path.exists(rsp_cache_file_path):
with open(rsp_cache_file_path, "r") as f1:
rsp_cache_json = json.load(f1)

77
tests/data/rsp_cache.json Normal file

File diff suppressed because one or more lines are too long

View file

@ -14,6 +14,7 @@ from metagpt.tools.translator import Translator
@pytest.mark.asyncio
@pytest.mark.usefixtures("llm_api")
@pytest.mark.usefixtures("llm_mock")
async def test_translate(llm_api):
poetries = [
("Let life be beautiful like summer flowers", ""),