From fad7c458ca6b37c7cf32dc45d177a1c2e1ccc63d Mon Sep 17 00:00:00 2001 From: Tim Pansino Date: Wed, 11 Oct 2023 11:23:22 -0700 Subject: [PATCH] Update OpenAI testing infra to match bedrock --- .../_mock_external_openai_server.py} | 0 tests/mlmodel_openai/conftest.py | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) rename tests/{testing_support/mock_external_openai_server.py => mlmodel_openai/_mock_external_openai_server.py} (100%) diff --git a/tests/testing_support/mock_external_openai_server.py b/tests/mlmodel_openai/_mock_external_openai_server.py similarity index 100% rename from tests/testing_support/mock_external_openai_server.py rename to tests/mlmodel_openai/_mock_external_openai_server.py diff --git a/tests/mlmodel_openai/conftest.py b/tests/mlmodel_openai/conftest.py index 900c43a812..5927dc5015 100644 --- a/tests/mlmodel_openai/conftest.py +++ b/tests/mlmodel_openai/conftest.py @@ -12,10 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import os -import pprint import pytest +from _mock_external_openai_server import ( + MockExternalOpenAIServer, + extract_shortened_prompt, +) from testing_support.fixture.event_loop import ( # noqa: F401; pylint: disable=W0611 event_loop as loop, ) @@ -23,10 +27,6 @@ collector_agent_registration_fixture, collector_available_fixture, ) -from testing_support.mock_external_openai_server import ( - MockExternalOpenAIServer, - extract_shortened_prompt, -) from newrelic.common.object_wrapper import wrap_function_wrapper @@ -78,7 +78,7 @@ def openai_server(): # Write responses to audit log with open(OPENAI_AUDIT_LOG_FILE, "w") as audit_log_fp: - pprint.pprint(OPENAI_AUDIT_LOG_CONTENTS, stream=audit_log_fp) + json.dump(OPENAI_AUDIT_LOG_CONTENTS, fp=audit_log_fp, indent=4) # Intercept outgoing requests and log to file for mocking