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] OllamaEmbedder.get_embedding() always returns empty list #2248

Open
Jiangwlee opened this issue Feb 27, 2025 · 0 comments
Open

[Bug] OllamaEmbedder.get_embedding() always returns empty list #2248

Jiangwlee opened this issue Feb 27, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Jiangwlee
Copy link

Description

OllamaEmbedder.get_embedding() always returns empty list.

Steps to Reproduce

Run following test code:

from agno.embedder.ollama import OllamaEmbedder

embeddings = OllamaEmbedder().get_embedding("The quick brown fox jumps over the lazy dog.")

Expected Behavior

Return the embedding result as a list.

Actual Behavior

It always return empty list

Root Cause

It is caused by wrong key in ollama response:

https://github.com/agno-agi/agno/blob/main/libs/agno/agno/embedder/ollama.py

    def get_embedding(self, text: str) -> List[float]:
        try:
            response = self._response(text=text)
            if response is None:
                return []
            return response.get("embedding", [])
        except Exception as e:
            logger.warning(e)
            return []

According to Ollama document "https://ollama.com/blog/embedding-models", the key in ollama response should be "embeddings", instead of "embedding".

@Jiangwlee Jiangwlee added the bug Something isn't working label Feb 27, 2025
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