Skip to content

Commit

Permalink
fix cassettes recording (Significant-Gravitas#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
waynehamadi authored Apr 26, 2023
1 parent cd8fdb3 commit 7a006af
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ interactions:
- Wed, 26 Apr 2023 16:40:03 GMT
Server:
- cloudflare
Transfer-Encoding:
- chunked
access-control-allow-origin:
- '*'
alt-svc:
Expand Down Expand Up @@ -213,8 +211,6 @@ interactions:
- Wed, 26 Apr 2023 16:40:20 GMT
Server:
- cloudflare
Transfer-Encoding:
- chunked
access-control-allow-origin:
- '*'
alt-svc:
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/goal_oriented/test_write_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/vcr/openai_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7a006af

Please sign in to comment.