()
| 382 | |
| 383 | |
| 384 | async def test_async_caching(): |
| 385 | messages = [{"role": "system", "content": f"{random_letters} count to 10"}] |
| 386 | completion = await client.chat.completions.create( |
| 387 | model="openpipe:test-content-35", |
| 388 | messages=messages, |
| 389 | openpipe={"tags": {"prompt_id": "test_async_caching"}}, |
| 390 | ) |
| 391 | await asyncio.sleep(0.1) |
| 392 | completion = await client.chat.completions.create( |
| 393 | model="openpipe:test-content-35", |
| 394 | messages=messages, |
| 395 | openpipe={"tags": {"prompt_id": "test_async_caching"}}, |
| 396 | ) |
| 397 | |
| 398 | if not TEST_LAST_LOGGED: |
| 399 | return |
| 400 | |
| 401 | await asyncio.sleep(0.1) |
| 402 | last_logged = ( |
| 403 | await client.openpipe_reporting_client.base_client.local_testing_only_get_latest_logged_call() |
| 404 | ) |
| 405 | assert last_logged.cache_hit == False |
| 406 | |
| 407 | completion = await client.chat.completions.create( |
| 408 | model="openpipe:test-content-35", |
| 409 | messages=messages, |
| 410 | openpipe={"tags": {"prompt_id": "test_async_caching"}, "cache": True}, |
| 411 | ) |
| 412 | await asyncio.sleep(0.1) |
| 413 | completion = await client.chat.completions.create( |
| 414 | model="openpipe:test-content-35", |
| 415 | messages=messages, |
| 416 | openpipe={"tags": {"prompt_id": "test_async_caching"}, "cache": True}, |
| 417 | ) |
| 418 | |
| 419 | await asyncio.sleep(0.1) |
| 420 | last_logged = ( |
| 421 | await client.openpipe_reporting_client.base_client.local_testing_only_get_latest_logged_call() |
| 422 | ) |
| 423 | assert last_logged.cache_hit == True |
| 424 | |
| 425 | |
| 426 | async def test_async_default_base_url(): |
nothing calls this directly
no test coverage detected