Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b800cd2
Add OpenSearch multimodal multi-embedding component
edwinjosechittilappilly Nov 25, 2025
30aefae
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 25, 2025
418b976
Merge branch 'main' into opensearch-multi-embedding
edwinjosechittilappilly Nov 25, 2025
2da5342
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 25, 2025
e3d90dd
Add EmbeddingsWithModels and sync model fetching
edwinjosechittilappilly Nov 25, 2025
491dc80
Merge branch 'opensearch-multi-embedding' of https://github.com/langf…
edwinjosechittilappilly Nov 25, 2025
693e7d5
Refactor embedding model component to use async Ollama model fetch
edwinjosechittilappilly Nov 25, 2025
bfbeec3
update to embeddings to support multiple models
edwinjosechittilappilly Nov 25, 2025
cf3435d
Add Notion integration components
edwinjosechittilappilly Nov 25, 2025
e59d1cc
Add tests for multi-model embeddings and OpenSearch
edwinjosechittilappilly Nov 25, 2025
095c60a
Merge branch 'main' into opensearch-multi-embedding
edwinjosechittilappilly Nov 25, 2025
3cc7b77
Update component_index.json
edwinjosechittilappilly Nov 25, 2025
44c27a9
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 25, 2025
9670f95
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 25, 2025
9ddd5af
Fix session_id handling in ChatInput and ChatOutput
edwinjosechittilappilly Nov 25, 2025
7ac4c77
Merge branch 'opensearch-multi-embedding' of https://github.com/langf…
edwinjosechittilappilly Nov 25, 2025
79153e6
Update test_opensearch_multimodal.py
edwinjosechittilappilly Nov 25, 2025
7bcb66a
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 25, 2025
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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/lfx/src/lfx/_assets/component_index.json

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions src/lfx/src/lfx/base/embeddings/embeddings_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""Extended embeddings class with available models metadata."""

from langchain_core.embeddings import Embeddings


class EmbeddingsWithModels(Embeddings):
"""Extended Embeddings class that includes available models with dedicated instances.

This class inherits from LangChain Embeddings and provides a mapping of model names
to their dedicated embedding instances, enabling multi-model support without the need
for dynamic model switching.

Attributes:
embeddings: The primary LangChain Embeddings instance (used as fallback).
available_models: Dict mapping model names to their dedicated Embeddings instances.
Each model has its own pre-configured instance with specific parameters.
"""

def __init__(
self,
embeddings: Embeddings,
available_models: dict[str, Embeddings] | None = None,
):
"""Initialize the EmbeddingsWithModels wrapper.

Args:
embeddings: The primary LangChain Embeddings instance (used as default/fallback).
available_models: Dict mapping model names to dedicated Embeddings instances.
Each value should be a fully configured Embeddings object ready to use.
Defaults to empty dict if not provided.
"""
super().__init__()
self.embeddings = embeddings
self.available_models = available_models if available_models is not None else {}

def embed_documents(self, texts: list[str]) -> list[list[float]]:
"""Embed search docs by delegating to the underlying embeddings instance.

Args:
texts: List of text to embed.

Returns:
List of embeddings.
"""
return self.embeddings.embed_documents(texts)

def embed_query(self, text: str) -> list[float]:
"""Embed query text by delegating to the underlying embeddings instance.

Args:
text: Text to embed.

Returns:
Embedding.
"""
return self.embeddings.embed_query(text)

async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
"""Asynchronously embed search docs.

Args:
texts: List of text to embed.

Returns:
List of embeddings.
"""
return await self.embeddings.aembed_documents(texts)

async def aembed_query(self, text: str) -> list[float]:
"""Asynchronously embed query text.

Args:
text: Text to embed.

Returns:
Embedding.
"""
return await self.embeddings.aembed_query(text)

def __call__(self, *args, **kwargs):
"""Make the class callable by delegating to the underlying embeddings instance.

This handles cases where the embeddings object is used as a callable.

Args:
*args: Positional arguments to pass to the underlying embeddings instance.
**kwargs: Keyword arguments to pass to the underlying embeddings instance.

Returns:
The result of calling the underlying embeddings instance.
"""
if callable(self.embeddings):
return self.embeddings(*args, **kwargs)
msg = f"'{type(self.embeddings).__name__}' object is not callable"
raise TypeError(msg)

def __getattr__(self, name: str):
"""Delegate attribute access to the underlying embeddings instance.

This ensures full compatibility with any additional methods or attributes
that the underlying embeddings instance might have.

Args:
name: The attribute name to access.

Returns:
The attribute from the underlying embeddings instance.
"""
return getattr(self.embeddings, name)

def __repr__(self) -> str:
"""Return string representation of the wrapper."""
return (
f"EmbeddingsWithModels(embeddings={self.embeddings!r}, "
f"available_models={self.available_models!r})"
)

Loading