Add project tools and contributing guidelines (#281)
This commit is contained in:
@@ -1 +1,10 @@
|
||||
from .embedchain import App, OpenSourceApp, PersonApp, PersonOpenSourceApp
|
||||
import importlib.metadata
|
||||
|
||||
__version__ = importlib.metadata.version(__package__ or __name__)
|
||||
|
||||
from .embedchain import (
|
||||
App, # noqa: F401
|
||||
OpenSourceApp, # noqa: F401
|
||||
PersonApp, # noqa: F401
|
||||
PersonOpenSourceApp, # noqa: F401
|
||||
)
|
||||
|
||||
@@ -3,10 +3,12 @@ import os
|
||||
from chromadb.utils import embedding_functions
|
||||
from embedchain.config.BaseConfig import BaseConfig
|
||||
|
||||
|
||||
class InitConfig(BaseConfig):
|
||||
"""
|
||||
Config to initialize an embedchain `App` instance.
|
||||
"""
|
||||
|
||||
def __init__(self, log_level=None, ef=None, db=None, host=None, port=None, id=None):
|
||||
"""
|
||||
:param log_level: Optional. (String) Debug level
|
||||
@@ -21,10 +23,11 @@ class InitConfig(BaseConfig):
|
||||
|
||||
if db is None:
|
||||
from embedchain.vectordb.chroma_db import ChromaDB
|
||||
self.db = ChromaDB(ef=self.ef)
|
||||
|
||||
self.db = ChromaDB(ef=ef)
|
||||
else:
|
||||
self.db = db
|
||||
|
||||
|
||||
self.ef = ef
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from .AddConfig import AddConfig
|
||||
from .BaseConfig import BaseConfig
|
||||
from .ChatConfig import ChatConfig
|
||||
from .InitConfig import InitConfig
|
||||
from .QueryConfig import QueryConfig
|
||||
from .AddConfig import AddConfig # noqa: F401
|
||||
from .BaseConfig import BaseConfig # noqa: F401
|
||||
from .ChatConfig import ChatConfig # noqa: F401
|
||||
from .InitConfig import InitConfig # noqa: F401
|
||||
from .QueryConfig import QueryConfig # noqa: F401
|
||||
|
||||
@@ -1 +1 @@
|
||||
from .data_formatter import DataFormatter
|
||||
from .data_formatter import DataFormatter # noqa: F401
|
||||
|
||||
@@ -97,11 +97,11 @@ class EmbedChain:
|
||||
metadatas = embeddings_data["metadatas"]
|
||||
ids = embeddings_data["ids"]
|
||||
# get existing ids, and discard doc if any common id exist.
|
||||
where={"app_id": self.config.id} if self.config.id is not None else {}
|
||||
where = {"app_id": self.config.id} if self.config.id is not None else {}
|
||||
# where={"url": src}
|
||||
existing_docs = self.collection.get(
|
||||
ids=ids,
|
||||
where=where, # optional filter
|
||||
where=where, # optional filter
|
||||
)
|
||||
existing_ids = set(existing_docs["ids"])
|
||||
|
||||
@@ -115,9 +115,9 @@ class EmbedChain:
|
||||
|
||||
ids = list(data_dict.keys())
|
||||
documents, metadatas = zip(*data_dict.values())
|
||||
|
||||
|
||||
# Add app id in metadatas so that they can be queried on later
|
||||
if (self.config.id is not None):
|
||||
if self.config.id is not None:
|
||||
metadatas = [{**m, "app_id": self.config.id} for m in metadatas]
|
||||
|
||||
chunks_before_addition = self.count()
|
||||
@@ -150,9 +150,11 @@ class EmbedChain:
|
||||
:param config: The query configuration.
|
||||
:return: The content of the document that matched your query.
|
||||
"""
|
||||
where = {"app_id": self.config.id} if self.config.id is not None else {} # optional filter
|
||||
where = {"app_id": self.config.id} if self.config.id is not None else {} # optional filter
|
||||
result = self.collection.query(
|
||||
query_texts=[input_query,],
|
||||
query_texts=[
|
||||
input_query,
|
||||
],
|
||||
n_results=config.number_documents,
|
||||
where=where,
|
||||
)
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.0.22"
|
||||
__version__ = "0.0.23"
|
||||
|
||||
Reference in New Issue
Block a user