Add Huggingface embeddings and Cohere embeddings (#63)
* Add huggingface embeddings and cohere embeddings * Update openai interface and the mock for newer OpenAI SDK --------- Co-authored-by: trducng <trungduc1992@gmail.com>
This commit is contained in:
12
knowledgehub/embeddings/cohere.py
Normal file
12
knowledgehub/embeddings/cohere.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from langchain.embeddings import CohereEmbeddings as LCCohereEmbeddings
|
||||
|
||||
from kotaemon.embeddings.base import LangchainEmbeddings
|
||||
|
||||
|
||||
class CohereEmbdeddings(LangchainEmbeddings):
|
||||
"""Cohere embeddings.
|
||||
|
||||
This class wraps around the Langchain CohereEmbeddings class.
|
||||
"""
|
||||
|
||||
_lc_class = LCCohereEmbeddings
|
12
knowledgehub/embeddings/huggingface.py
Normal file
12
knowledgehub/embeddings/huggingface.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from langchain.embeddings import HuggingFaceBgeEmbeddings as LCHuggingFaceEmbeddings
|
||||
|
||||
from kotaemon.embeddings.base import LangchainEmbeddings
|
||||
|
||||
|
||||
class HuggingFaceEmbeddings(LangchainEmbeddings):
|
||||
"""HuggingFace embeddings
|
||||
|
||||
This class wraps around the Langchain HuggingFaceEmbeddings class
|
||||
"""
|
||||
|
||||
_lc_class = LCHuggingFaceEmbeddings
|
@@ -8,7 +8,7 @@ from ..base import BaseComponent
|
||||
from ..documents.base import Document
|
||||
|
||||
|
||||
class AutoReader(BaseComponent, BaseReader):
|
||||
class AutoReader(BaseComponent):
|
||||
"""General auto reader for a variety of files. (based on llama-hub)"""
|
||||
|
||||
def __init__(self, reader_type: Union[str, Type[BaseReader]]) -> None:
|
||||
@@ -31,7 +31,7 @@ class AutoReader(BaseComponent, BaseReader):
|
||||
return self.load_data(file=file, **kwargs)
|
||||
|
||||
|
||||
class LIBaseReader(BaseComponent, BaseReader):
|
||||
class LIBaseReader(BaseComponent):
|
||||
_reader_class: Type[BaseReader]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@@ -75,8 +75,8 @@ class Planner(BaseComponent):
|
||||
try:
|
||||
response = self.model(prompt)
|
||||
output.info("Planner run successful.")
|
||||
except ValueError:
|
||||
except ValueError as e:
|
||||
output.error("Planner failed to retrieve response from LLM")
|
||||
raise ValueError("Planner failed to retrieve response from LLM")
|
||||
raise ValueError("Planner failed to retrieve response from LLM") from e
|
||||
|
||||
return response
|
||||
|
Reference in New Issue
Block a user