77from langchain .retrievers import ContextualCompressionRetriever
88from langchain .retrievers .document_compressors import EmbeddingsFilter , DocumentCompressorPipeline
99from langchain_community .document_transformers import EmbeddingsRedundantFilter
10+ from langchain_community .embeddings import HuggingFaceHubEmbeddings
1011from langchain_community .vectorstores import FAISS
1112from langchain_openai import OpenAIEmbeddings , AzureOpenAIEmbeddings
12- from ..models import OpenAI , Ollama , AzureOpenAI
13+ from ..models import OpenAI , Ollama , AzureOpenAI , HuggingFace
1314from langchain_community .embeddings import OllamaEmbeddings
1415from .base_node import BaseNode
1516
@@ -26,11 +27,11 @@ class RAGNode(BaseNode):
2627 node_type (str): The type of the node, set to "node" indicating a standard operational node.
2728
2829 Args:
29- node_name (str, optional): The unique identifier name for the node.
30+ node_name (str, optional): The unique identifier name for the node.
3031 Defaults to "ParseHTMLNode".
3132
3233 Methods:
33- execute(state): Parses the HTML document contained within the state using
34+ execute(state): Parses the HTML document contained within the state using
3435 the specified tags, if provided, and updates the state with the parsed content.
3536 """
3637
@@ -44,7 +45,7 @@ def __init__(self, input: str, output: List[str], node_config: dict, node_name:
4445
4546 def execute (self , state ):
4647 """
47- Executes the node's logic to implement RAG (Retrieval-Augmented Generation)
48+ Executes the node's logic to implement RAG (Retrieval-Augmented Generation)
4849 The method updates the state with relevant chunks of the document.
4950
5051 Args:
@@ -54,7 +55,7 @@ def execute(self, state):
5455 dict: The updated state containing the 'relevant_chunks' key with the relevant chunks.
5556
5657 Raises:
57- KeyError: If 'document' is not found in the state, indicating that the necessary
58+ KeyError: If 'document' is not found in the state, indicating that the necessary
5859 information for parsing is missing.
5960 """
6061
@@ -92,6 +93,8 @@ def execute(self, state):
9293 embeddings = AzureOpenAIEmbeddings ()
9394 elif isinstance (embedding_model , Ollama ):
9495 embeddings = OllamaEmbeddings (model = embedding_model .model )
96+ elif isinstance (embedding_model , HuggingFace ):
97+ embeddings = HuggingFaceHubEmbeddings (model = embedding_model .model )
9598 else :
9699 raise ValueError ("Embedding Model missing or not supported" )
97100
0 commit comments