Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
let(:client) do
OpenAI::Client.new(
access_token: "sk-1234",
uri_base: "http://0.0.0.0:4000/openai"
uri_base: "http://0.0.0.0:4000/openai",
request_timeout: 600
)
end

Expand Down
26 changes: 16 additions & 10 deletions tests/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,23 @@ async def retry_request(func, *args, _max_attempts=5, **kwargs):
assert spend > 0

# The record/replay proxy serves this identical second call from its
# cassette (free), but the proxy must still bill it. If the proxy's own
# response cache were on, the repeat would be a $0 cache hit and spend
# would not move, silently zeroing recorded-call spend; assert it grows.
# cassette (free), but the proxy must still bill it. Spend logging is
# async/batched, so poll for the increase rather than reading once after a
# fixed sleep; a spend that never grows means the repeat was not billed
# (e.g. the proxy response cache is on), which this still catches.
await image_generation(session=session, key=key)
await asyncio.sleep(5)
key_info = await retry_request(
get_key_info, session=session, get_key=key, call_key=key
)
assert key_info["info"]["spend"] > spend, (
"spend did not increase on an identical repeat image call; the proxy "
"response cache appears to be ON, which would zero recorded-call spend"
spend_after = spend
for _ in range(12):
await asyncio.sleep(5)
key_info = await retry_request(
get_key_info, session=session, get_key=key, call_key=key
)
spend_after = key_info["info"]["spend"]
if spend_after > spend:
break
assert spend_after > spend, (
"spend did not increase on an identical repeat image call; the repeat "
"was not billed (the proxy response cache may be on)"
)


Expand Down
Loading