fix(bedrock.py): fix embeddings call

This commit is contained in:
Krrish Dholakia 2023-12-06 14:15:53 -08:00
parent be15cf20b9
commit f1c1ec8523
3 changed files with 6 additions and 5 deletions

View file

@ -552,8 +552,8 @@ def _embedding_func_single(
## FORMAT EMBEDDING INPUT ##
provider = model.split(".")[0]
inference_params = copy.deepcopy(optional_params)
input = input.replace(os.linesep, " ")
if provider == "amazon":
input = input.replace(os.linesep, " ")
data = {"inputText": input, **inference_params}
# data = json.dumps(data)
elif provider == "cohere":
@ -577,7 +577,7 @@ def _embedding_func_single(
try:
response = client.invoke_model(
body=body,
modelId="cohere.embed-multilingual-v3",
modelId=model,
accept="*/*",
contentType="application/json",
)

View file

@ -153,6 +153,7 @@ def test_cohere_embedding3():
def test_bedrock_embedding_titan():
try:
litellm.set_verbose=True
response = embedding(
model="amazon.titan-embed-text-v1", input=["good morning from litellm, attempting to embed data",
"lets test a second string for good measure"]
@ -160,7 +161,7 @@ def test_bedrock_embedding_titan():
print(f"response:", response)
except Exception as e:
pytest.fail(f"Error occurred: {e}")
# test_bedrock_embedding()
test_bedrock_embedding_titan()
def test_bedrock_embedding_cohere():
try:
@ -173,7 +174,7 @@ def test_bedrock_embedding_cohere():
except Exception as e:
pytest.fail(f"Error occurred: {e}")
test_bedrock_embedding_cohere()
# test_bedrock_embedding_cohere()
# comment out hf tests - since hf endpoints are unstable
def test_hf_embedding():

View file

@ -1,6 +1,6 @@
# #### What this tests ####
# # Allow the user to easily run the local proxy server with Gunicorn
## LOCAL TESTING ONLY
# # LOCAL TESTING ONLY
# import sys, os, subprocess
# import traceback
# from dotenv import load_dotenv