(fix) use isinstance to check types

This commit is contained in:
ishaan-jaff 2024-01-30 08:31:21 -08:00
parent b9a117fa1d
commit f941c57688

View file

@ -702,7 +702,7 @@ def _embedding_func_single(
encoding=None, encoding=None,
logging_obj=None, logging_obj=None,
): ):
if type(input) != str: if isinstance(input, str) is False:
raise BedrockError( raise BedrockError(
message="Bedrock Embedding API input must be type str | List[str]", message="Bedrock Embedding API input must be type str | List[str]",
status_code=400, status_code=400,
@ -800,7 +800,8 @@ def embedding(
aws_role_name=aws_role_name, aws_role_name=aws_role_name,
aws_session_name=aws_session_name, aws_session_name=aws_session_name,
) )
if type(input) == str: if isinstance(input, str):
## Embedding Call
embeddings = [ embeddings = [
_embedding_func_single( _embedding_func_single(
model, model,
@ -810,8 +811,8 @@ def embedding(
logging_obj=logging_obj, logging_obj=logging_obj,
) )
] ]
elif type(input) == list: elif isinstance(input, list):
## Embedding Call ## Embedding Call - assuming this is a List[str]
embeddings = [ embeddings = [
_embedding_func_single( _embedding_func_single(
model, model,