forked from phoenix/litellm-mirror
test whisper
This commit is contained in:
parent
ec3b0d0d0b
commit
d6c3560ff1
2 changed files with 45 additions and 0 deletions
BIN
litellm/tests/eagle.wav
Normal file
BIN
litellm/tests/eagle.wav
Normal file
Binary file not shown.
|
@ -26,6 +26,10 @@ file_path = os.path.join(pwd, "gettysburg.wav")
|
|||
|
||||
audio_file = open(file_path, "rb")
|
||||
|
||||
|
||||
file2_path = os.path.join(pwd, "eagle.wav")
|
||||
audio_file2 = open(file2_path, "rb")
|
||||
|
||||
load_dotenv()
|
||||
|
||||
sys.path.insert(
|
||||
|
@ -148,3 +152,44 @@ async def test_transcription_on_router():
|
|||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
pytest.fail(f"Error occurred: {e}")
|
||||
|
||||
|
||||
@pytest.mark.asyncio()
|
||||
async def test_transcription_caching():
|
||||
import litellm
|
||||
from litellm.caching import Cache
|
||||
|
||||
litellm.set_verbose = True
|
||||
litellm.cache = Cache()
|
||||
|
||||
# make raw llm api call
|
||||
|
||||
response_1 = await litellm.atranscription(
|
||||
model="whisper-1",
|
||||
file=audio_file,
|
||||
)
|
||||
|
||||
await asyncio.sleep(5)
|
||||
|
||||
# cache hit
|
||||
|
||||
response_2 = await litellm.atranscription(
|
||||
model="whisper-1",
|
||||
file=audio_file,
|
||||
)
|
||||
|
||||
print("response_1", response_1)
|
||||
print("response_2", response_2)
|
||||
print("response2 hidden params", response_2._hidden_params)
|
||||
assert response_2._hidden_params["cache_hit"] is True
|
||||
|
||||
# cache miss
|
||||
|
||||
response_3 = await litellm.atranscription(
|
||||
model="whisper-1",
|
||||
file=audio_file2,
|
||||
)
|
||||
print("response_3", response_3)
|
||||
print("response3 hidden params", response_3._hidden_params)
|
||||
assert response_3._hidden_params.get("cache_hit") is not True
|
||||
assert response_3.text != response_2.text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue