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

NotImplementedError in FastEmbedEmbedder #1715

Closed
rpvitruvix opened this issue Jan 7, 2025 · 2 comments · Fixed by #1745
Closed

NotImplementedError in FastEmbedEmbedder #1715

rpvitruvix opened this issue Jan 7, 2025 · 2 comments · Fixed by #1745

Comments

@rpvitruvix
Copy link

Context

I'm learning to use Phidata. Trying to implement a basic document loader with FastEmbedEmbedder.

Problem

FastEmbedEmbedder raises NotImplementedError when trying to load documents into knowledge base.

Code

from phi.agent import Agent
from phi.model.anthropic import Claude
from phi.knowledge.docx import DocxKnowledgeBase
from phi.vectordb.chroma import ChromaDb
from phi.embedder.fastembed import FastEmbedEmbedder

model = Claude(temperature=0.3)
vector_db = ChromaDb(
    path="temp/chromadb",
    collection="docs",
    embedder=FastEmbedEmbedder(),
)
knowledge_base = DocxKnowledgeBase(
    path="temp",
    formats=[".doc", ".docx"],
    vector_db=vector_db,
    optimize_on=3,
)
agent = Agent(
    model=model,
    knowledge_base=knowledge_base,
    search_knowledge=True,
    debug_mode=True,
    show_tool_calls=True
)

agent.knowledge.load(upsert=True)  # Error occurs here

Error

Traceback (most recent call last):
  File "path/to/project/my_agent.py", line 31, in <module>
    agent.knowledge.load(upsert=True)
  File "path/to/python/site-packages/phi/knowledge/agent.py", line 104, in load
    self.vector_db.insert(documents=documents_to_load, filters=filters)
  File "path/to/python/site-packages/phi/vectordb/chroma/chromadb.py", line 133, in insert
    document.embed(embedder=self.embedder)
  File "path/to/python/site-packages/phi/document/base.py", line 29, in embed
    self.embedding, self.usage = *embedder.get*embedding_and_usage(self.content)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "path/to/python/site-packages/phi/embedder/fastembed.py", line 30, in get_embedding_and_usage
    return super().get_embedding_and_usage(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "path/to/python/site-packages/phi/embedder/base.py", line 17, in get_embedding_and_usage
    raise NotImplementedError
NotImplementedError
@45-Hrishi
Copy link

45-Hrishi commented Jan 7, 2025

I am also facing the same error. I guess the error is due to this implementation.
image

@ysolanky ysolanky mentioned this issue Jan 10, 2025
12 tasks
@ysolanky
Copy link
Contributor

Hello @rpvitruvix @45-Hrishi ! I have fixed this issue here: #1745

It will be a part of the next release

ysolanky added a commit that referenced this issue Jan 13, 2025
## Description

Updated `get_embedding_and_usage` function of `FastEmbedEmbedder`. 

Fixes #1715 

## Type of change

Please check the options that are relevant:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Model update
- [ ] Infrastructure change

## Checklist

- [ ] My code follows Phidata's style guidelines and best practices
- [ ] I have performed a self-review of my code
- [ ] I have added docstrings and comments for complex logic
- [ ] My changes generate no new warnings or errors
- [ ] I have added cookbook examples for my new addition (if needed)
- [ ] I have updated requirements.txt/pyproject.toml (if needed)
- [ ] I have verified my changes in a clean environment

Notes:

`FastEmbedEmbedder` currently does not provide usage information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants