Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: validation error when using bedrock for embedding #1660

Open
lironrisk opened this issue Jan 21, 2024 · 0 comments
Open

[Bug]: validation error when using bedrock for embedding #1660

lironrisk opened this issue Jan 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lironrisk
Copy link

What happened?

I'm getting a validation error when using bedrock for embedding:
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #: required key [texts] not found#: required key [input_type] not found#: extraneous key [inputText] is not permitted, please reformat your input and try again

this is the code snippet:
`embedding_function = embedding_functions.AmazonBedrockEmbeddingFunction(session=session, model_name="cohere.embed-english-v3")
collection = persistent_client.get_or_create_collection("c_data", embedding_function=embedding_function)

load txt files

loader = DirectoryLoader("./confluence_data/", loader_cls=TextLoader, silent_errors=True)

documents = loader.load()
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)

for doc in docs:
    print(doc.metadata)
    collection.add(
        ids=[str(uuid.uuid1())], metadatas=doc.metadata, documents=doc.page_content
    )`

full error:
File "main.py", line 188, in load_data_to_db collection.add( File "/usr/local/lib/python3.11/site-packages/chromadb/api/models/Collection.py", line 154, in add embeddings = self._embed(input=documents) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/chromadb/api/models/Collection.py", line 633, in _embed return self._embedding_function(input=input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/chromadb/utils/embedding_functions.py", line 751, in __call__ response = self._client.invoke_model( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/botocore/client.py", line 553, in _api_call return self._make_api_call(operation_name, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/botocore/client.py", line 1015, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the InvokeModel operation: Malformed input request: #: required key [texts] not found#: required key [input_type] not found#: extraneous key [inputText] is not permitted, please reformat your input and try again.

Versions

chroma v[0.4.22]
Python 3.11.6
boto3 Version: 1.34.23
OS: Mac M1 Pro

Relevant log output

No response

@lironrisk lironrisk added the bug Something isn't working label Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant