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

feat: adds LangChain Fake Embeddings #4789

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .character import CharacterTextSplitterComponent
from .conversation import ConversationChainComponent
from .csv import CSVAgentComponent
from .fake_embeddings import FakeEmbeddingsComponent
from .html_link_extractor import HtmlLinkExtractorComponent
from .json import JsonAgentComponent
from .json_document_builder import JSONDocumentBuilder
Expand Down Expand Up @@ -30,6 +31,7 @@
"CharacterTextSplitterComponent",
"ConversationChainComponent",
"CSVAgentComponent",
"FakeEmbeddingsComponent",
"HtmlLinkExtractorComponent",
"JSONDocumentBuilder",
"JsonAgentComponent",
Expand Down
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,
)