forked from phoenix/litellm-mirror
(test) embedding stricter testing
This commit is contained in:
parent
e8ff4d5eca
commit
40dd38508f
1 changed files with 22 additions and 4 deletions
|
@ -1,6 +1,9 @@
|
||||||
import sys, os
|
import sys, os
|
||||||
import traceback
|
import traceback
|
||||||
import pytest
|
import pytest
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
sys.path.insert(
|
sys.path.insert(
|
||||||
0, os.path.abspath("../..")
|
0, os.path.abspath("../..")
|
||||||
|
@ -15,12 +18,27 @@ def test_openai_embedding():
|
||||||
response = embedding(
|
response = embedding(
|
||||||
model="text-embedding-ada-002", input=["good morning from litellm", "this is another item"]
|
model="text-embedding-ada-002", input=["good morning from litellm", "this is another item"]
|
||||||
)
|
)
|
||||||
print(response)
|
litellm_response = dict(response)
|
||||||
# Add any assertions here to check the response
|
litellm_response_keys = set(litellm_response.keys())
|
||||||
# print(f"response: {str(response)}")
|
print(litellm_response_keys)
|
||||||
|
print("LiteLLM Response\n")
|
||||||
|
print(litellm_response)
|
||||||
|
|
||||||
|
# same request with OpenAI 1.0+
|
||||||
|
import openai
|
||||||
|
client = openai.OpenAI(api_key=os.environ['OPENAI_API_KEY'])
|
||||||
|
response = client.embeddings.create(
|
||||||
|
model="text-embedding-ada-002", input=["good morning from litellm", "this is another item"]
|
||||||
|
)
|
||||||
|
|
||||||
|
response = dict(response)
|
||||||
|
openai_response_keys = set(response.keys())
|
||||||
|
assert litellm_response_keys == openai_response_keys # ENSURE the Keys in litellm response is exactly what the openai package returns
|
||||||
|
assert len(litellm_response["data"]) == 2 # expect two embedding responses from litellm_response since input had two
|
||||||
|
print(openai_response_keys)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pytest.fail(f"Error occurred: {e}")
|
pytest.fail(f"Error occurred: {e}")
|
||||||
# test_openai_embedding()
|
test_openai_embedding()
|
||||||
|
|
||||||
def test_openai_azure_embedding_simple():
|
def test_openai_azure_embedding_simple():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue