diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 3c2e02b3..4534bce8 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,6 +1,6 @@ import pytest -from tests.vcr.openai_filter import before_record_request +from tests.vcr.openai_filter import before_record_request, before_record_response @pytest.fixture @@ -9,8 +9,9 @@ def vcr_config(): return { "record_mode": "new_episodes", "before_record_request": before_record_request, + "before_record_response": before_record_response, "filter_headers": [ - "authorization", + "Authorization", "X-OpenAI-Client-User-Agent", "User-Agent", ], diff --git a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml index 1a5bba5c..482042f8 100644 --- a/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml +++ b/tests/integration/goal_oriented/cassettes/test_write_file/test_write_file.yaml @@ -86,8 +86,6 @@ interactions: - Wed, 26 Apr 2023 16:40:03 GMT Server: - cloudflare - Transfer-Encoding: - - chunked access-control-allow-origin: - '*' alt-svc: @@ -213,8 +211,6 @@ interactions: - Wed, 26 Apr 2023 16:40:20 GMT Server: - cloudflare - Transfer-Encoding: - - chunked access-control-allow-origin: - '*' alt-svc: diff --git a/tests/integration/goal_oriented/test_write_file.py b/tests/integration/goal_oriented/test_write_file.py index 92ebbc56..739b0f20 100644 --- a/tests/integration/goal_oriented/test_write_file.py +++ b/tests/integration/goal_oriented/test_write_file.py @@ -50,6 +50,9 @@ def create_writer_agent(workspace): ], ) ai_config.command_registry = command_registry + CFG.set_continuous_mode(True) + CFG.set_memory_backend("no_memory") + CFG.set_temperature(0) memory = get_memory(CFG, init=True) triggering_prompt = ( "Determine which next command to use, and respond using the" @@ -68,9 +71,7 @@ def create_writer_agent(workspace): triggering_prompt=triggering_prompt, workspace_directory=workspace.root, ) - CFG.set_continuous_mode(True) - CFG.set_memory_backend("no_memory") - CFG.set_temperature(0) + os.environ["TIKTOKEN_CACHE_DIR"] = "" return agent diff --git a/tests/vcr/openai_filter.py b/tests/vcr/openai_filter.py index 56a7eaec..b18b694b 100644 --- a/tests/vcr/openai_filter.py +++ b/tests/vcr/openai_filter.py @@ -26,6 +26,12 @@ def replace_timestamp_in_request(request): return request +def before_record_response(response): + if "Transfer-Encoding" in response["headers"]: + del response["headers"]["Transfer-Encoding"] + return response + + def before_record_request(request): filtered_request = filter_hostnames(request) filtered_request_without_dynamic_data = replace_timestamp_in_request(