mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
add litellm caching
This commit is contained in:
parent
9155ba068f
commit
77436cbcf4
3 changed files with 19 additions and 17 deletions
|
@ -4,4 +4,5 @@ python-dotenv
|
|||
openai
|
||||
tiktoken
|
||||
importlib_metadata
|
||||
baseten
|
||||
baseten
|
||||
gptcache
|
Binary file not shown.
|
@ -48,22 +48,23 @@ def test_caching_with_models():
|
|||
pytest.fail(f"Error occurred:")
|
||||
|
||||
|
||||
# def test_gpt_cache():
|
||||
# # INIT GPT Cache #
|
||||
# from gptcache import cache
|
||||
# cache.init()
|
||||
# cache.set_openai_key()
|
||||
def test_gpt_cache():
|
||||
# INIT GPT Cache #
|
||||
from gptcache import cache
|
||||
from litellm.cache import completion
|
||||
cache.init()
|
||||
cache.set_openai_key()
|
||||
|
||||
# messages = [{"role": "user", "content": "what is litellm this morning? "}]
|
||||
# response2 = litellm.cache.completion(model="gpt-3.5-turbo", messages=messages)
|
||||
# response3 = litellm.cache.completion(model="command-nightly", messages=messages)
|
||||
# print(f"response2: {response2}")
|
||||
# print(f"response3: {response3}")
|
||||
messages = [{"role": "user", "content": "what is litellm YC 22?"}]
|
||||
response2 = completion(model="gpt-3.5-turbo", messages=messages)
|
||||
response3 = completion(model="command-nightly", messages=messages)
|
||||
print(f"response2: {response2}")
|
||||
print(f"response3: {response3}")
|
||||
|
||||
if response3['choices'] != response2['choices']:
|
||||
# if models are different, it should not return cached response
|
||||
print(f"response2: {response2}")
|
||||
print(f"response3: {response3}")
|
||||
pytest.fail(f"Error occurred:")
|
||||
|
||||
# if response3 != response2:
|
||||
# # if models are different, it should not return cached response
|
||||
# print(f"response2: {response2}")
|
||||
# print(f"response3: {response3}")
|
||||
# pytest.fail(f"Error occurred:")
|
||||
|
||||
# test_gpt_cache()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue