python compat fixes

This commit is contained in:
Kyle Corbitt
2023-08-23 17:14:19 -07:00
parent f59150ff5b
commit 50a79b6e3a
4 changed files with 25 additions and 24 deletions

View File

@@ -27,12 +27,14 @@ def last_logged_call():
return local_testing_only_get_latest_logged_call.sync(client=configured_client)
@pytest.mark.focus
def test_sync():
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "system", "content": "count to 3"}],
)
print("completion is", completion)
last_logged = last_logged_call()
assert (
last_logged.model_response.resp_payload["choices"][0]["message"]["content"]
@@ -42,7 +44,7 @@ def test_sync():
last_logged.model_response.req_payload["messages"][0]["content"] == "count to 3"
)
assert completion.openpipe.cache_status == "SKIP"
assert completion.openpipe["cache_status"] == "SKIP"
def test_streaming():
@@ -75,7 +77,7 @@ async def test_async():
== "count down from 5"
)
assert completion.openpipe.cache_status == "SKIP"
assert completion.openpipe["cache_status"] == "SKIP"
async def test_async_streaming():
@@ -87,7 +89,7 @@ async def test_async_streaming():
merged = None
async for chunk in completion:
assert chunk.openpipe.cache_status == "SKIP"
assert chunk.openpipe["cache_status"] == "SKIP"
merged = merge_openai_chunks(merged, chunk)
last_logged = last_logged_call()
@@ -100,7 +102,7 @@ async def test_async_streaming():
last_logged.model_response.req_payload["messages"][0]["content"]
== "count down from 5"
)
assert merged["openpipe"].cache_status == "SKIP"
assert merged["openpipe"]["cache_status"] == "SKIP"
def test_sync_with_tags():
@@ -146,7 +148,7 @@ async def test_caching():
messages=messages,
openpipe={"cache": True},
)
assert completion.openpipe.cache_status == "MISS"
assert completion.openpipe["cache_status"] == "MISS"
first_logged = last_logged_call()
assert (
@@ -159,4 +161,4 @@ async def test_caching():
messages=messages,
openpipe={"cache": True},
)
assert completion2.openpipe.cache_status == "HIT"
assert completion2.openpipe["cache_status"] == "HIT"