forked from langflow-ai/langflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds LangChain Fake Embeddings (langflow-ai#4789)
adding LangChain Fake Embeddings Co-authored-by: Eric Hare <ericrhare@gmail.com>
- Loading branch information
1 parent
56c1dd7
commit f1adfd3
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/backend/base/langflow/components/langchain_utilities/fake_embeddings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from langchain_community.embeddings import FakeEmbeddings | ||
|
||
from langflow.base.embeddings.model import LCEmbeddingsModel | ||
from langflow.field_typing import Embeddings | ||
from langflow.io import IntInput | ||
|
||
|
||
class FakeEmbeddingsComponent(LCEmbeddingsModel): | ||
display_name = "Fake Embeddings" | ||
description = "Generate fake embeddings, useful for initial testing and connecting components." | ||
icon = "LangChain" | ||
name = "LangChainFakeEmbeddings" | ||
|
||
inputs = [ | ||
IntInput( | ||
name="dimensions", | ||
display_name="Dimensions", | ||
info="The number of dimensions the resulting output embeddings should have.", | ||
value=5, | ||
), | ||
] | ||
|
||
def build_embeddings(self) -> Embeddings: | ||
return FakeEmbeddings( | ||
size=self.dimensions or 5, | ||
) |