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]: Get vertex embeddings when using GoogleVertexEmbeddingFunction #1995

Open
pig7788 opened this issue Apr 10, 2024 · 2 comments
Open

[Bug]: Get vertex embeddings when using GoogleVertexEmbeddingFunction #1995

pig7788 opened this issue Apr 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pig7788
Copy link

pig7788 commented Apr 10, 2024

What happened?

When I call GoogleVertexEmbeddingFunction to get embeddings, it can't parse response appropriately.
code before fixed:

if "predictions" in response:
     embeddings.append(response["predictions"]["embeddings"]["values"])

when I print my response, it is like:

{
    'predictions': [{
        'embeddings': {
            'values': [ embedding values, ... ],
            'statistics': {
                'truncated': False,
                'token_count': 179
            }
        }
    }],
    'metadata': {
        'billableCharacterCount': 206
    }
}

The key 'predictions' corresponds to the value type which is list object.
So I guess the response which has changed from google vertex api.

After the code fixed like this:

if "predictions" in response:
     for prediction in response['predictions']:
           embeddings.append(prediction["embeddings"]["values"])

It runs well.

Versions

Chromadb 0.4.24
Python 3.10.13
MacOS 14.1

Relevant log output

File "/Users/liyuxiang/.pyenv/versions/butterbeer/lib/python3.10/site-packages/chromadb/utils/embedding_functions.py", line 668, in __call__
    embeddings.append(response["predictions"]["embeddings"]["values"])
TypeError: list indices must be integers or slices, not str
@pig7788 pig7788 added the bug Something isn't working label Apr 10, 2024
@nicolasgere
Copy link
Contributor

nicolasgere commented Apr 10, 2024

Thank you for the report, would be awesome if you could open a pr with your code change. If not, let me know, I would do it.

@pig7788
Copy link
Author

pig7788 commented Apr 11, 2024

I finish the pr after my code changed. Please help me check up, thank you!

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

2 participants