forked from phoenix/litellm-mirror
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
|
openai
|
||||||
tiktoken
|
tiktoken
|
||||||
importlib_metadata
|
importlib_metadata
|
||||||
baseten
|
baseten
|
||||||
|
gptcache
|
Binary file not shown.
|
@ -48,22 +48,23 @@ def test_caching_with_models():
|
||||||
pytest.fail(f"Error occurred:")
|
pytest.fail(f"Error occurred:")
|
||||||
|
|
||||||
|
|
||||||
# def test_gpt_cache():
|
def test_gpt_cache():
|
||||||
# # INIT GPT Cache #
|
# INIT GPT Cache #
|
||||||
# from gptcache import cache
|
from gptcache import cache
|
||||||
# cache.init()
|
from litellm.cache import completion
|
||||||
# cache.set_openai_key()
|
cache.init()
|
||||||
|
cache.set_openai_key()
|
||||||
|
|
||||||
# messages = [{"role": "user", "content": "what is litellm this morning? "}]
|
messages = [{"role": "user", "content": "what is litellm YC 22?"}]
|
||||||
# response2 = litellm.cache.completion(model="gpt-3.5-turbo", messages=messages)
|
response2 = completion(model="gpt-3.5-turbo", messages=messages)
|
||||||
# response3 = litellm.cache.completion(model="command-nightly", messages=messages)
|
response3 = completion(model="command-nightly", messages=messages)
|
||||||
# print(f"response2: {response2}")
|
print(f"response2: {response2}")
|
||||||
# print(f"response3: {response3}")
|
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