Spaces:
Runtime error
Runtime error
π§ Fix vectorstore typing
Browse files- README.md +1 -0
- megabots/__init__.py +3 -4
- megabots/vectorstores.py +9 -1
README.md
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
π€ Megabots provides State-of-the-art, production ready LLM apps made mega-easy, so you don't have to build them from scratch π€― Create a bot, now π«΅
|
7 |
|
8 |
π Join us on Discord: https://discord.gg/zkqDWk5S7P
|
|
|
9 |
|
10 |
The Megabots library can be used to create bots that:
|
11 |
|
|
|
6 |
π€ Megabots provides State-of-the-art, production ready LLM apps made mega-easy, so you don't have to build them from scratch π€― Create a bot, now π«΅
|
7 |
|
8 |
π Join us on Discord: https://discord.gg/zkqDWk5S7P
|
9 |
+
βοΈ Work is managed in this project: https://github.com/users/momegas/projects/5/views/2
|
10 |
|
11 |
The Megabots library can be used to create bots that:
|
12 |
|
megabots/__init__.py
CHANGED
@@ -13,7 +13,7 @@ from langchain.prompts import PromptTemplate
|
|
13 |
from langchain.chains.question_answering import load_qa_chain
|
14 |
from langchain.chains.conversational_retrieval.prompts import QA_PROMPT
|
15 |
from langchain.document_loaders import DirectoryLoader
|
16 |
-
from megabots.vectorstores import vectorstore
|
17 |
|
18 |
load_dotenv()
|
19 |
|
@@ -26,8 +26,7 @@ class Bot:
|
|
26 |
prompt_variables: list[str] | None = None,
|
27 |
index: str | None = None,
|
28 |
sources: bool | None = False,
|
29 |
-
|
30 |
-
vectorstore: Any | None = None,
|
31 |
memory: str | None = None,
|
32 |
verbose: bool = False,
|
33 |
temperature: int = 0,
|
@@ -84,7 +83,7 @@ class Bot:
|
|
84 |
)
|
85 |
self.loader = DirectoryLoader(index, recursive=True)
|
86 |
|
87 |
-
def load_or_create_index(self, index: str, vectorstore=None):
|
88 |
# Load an existing index from disk or create a new one if not available
|
89 |
if vectorstore is not None:
|
90 |
self.search_index = vectorstore.client.from_documents(
|
|
|
13 |
from langchain.chains.question_answering import load_qa_chain
|
14 |
from langchain.chains.conversational_retrieval.prompts import QA_PROMPT
|
15 |
from langchain.document_loaders import DirectoryLoader
|
16 |
+
from megabots.vectorstores import VectorStore, vectorstore
|
17 |
|
18 |
load_dotenv()
|
19 |
|
|
|
26 |
prompt_variables: list[str] | None = None,
|
27 |
index: str | None = None,
|
28 |
sources: bool | None = False,
|
29 |
+
vectorstore: VectorStore | None = None,
|
|
|
30 |
memory: str | None = None,
|
31 |
verbose: bool = False,
|
32 |
temperature: int = 0,
|
|
|
83 |
)
|
84 |
self.loader = DirectoryLoader(index, recursive=True)
|
85 |
|
86 |
+
def load_or_create_index(self, index: str, vectorstore: VectorStore | None = None):
|
87 |
# Load an existing index from disk or create a new one if not available
|
88 |
if vectorstore is not None:
|
89 |
self.search_index = vectorstore.client.from_documents(
|
megabots/vectorstores.py
CHANGED
@@ -10,6 +10,14 @@ class MilvusVectorStore:
|
|
10 |
self.client = Milvus
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
SUPPORTED_VECTORSTORES = {
|
14 |
"milvus": {
|
15 |
"impl": MilvusVectorStore,
|
@@ -18,7 +26,7 @@ SUPPORTED_VECTORSTORES = {
|
|
18 |
}
|
19 |
|
20 |
|
21 |
-
def vectorstore(name: str) ->
|
22 |
"""Return a vectorstore object."""
|
23 |
|
24 |
if name is None:
|
|
|
10 |
self.client = Milvus
|
11 |
|
12 |
|
13 |
+
class ChromaVectorStore:
|
14 |
+
pass
|
15 |
+
|
16 |
+
|
17 |
+
# Generic type variable for all vectorstores
|
18 |
+
VectorStore = type("VectorStore", (MilvusVectorStore, ChromaVectorStore), {})
|
19 |
+
|
20 |
+
|
21 |
SUPPORTED_VECTORSTORES = {
|
22 |
"milvus": {
|
23 |
"impl": MilvusVectorStore,
|
|
|
26 |
}
|
27 |
|
28 |
|
29 |
+
def vectorstore(name: str) -> VectorStore:
|
30 |
"""Return a vectorstore object."""
|
31 |
|
32 |
if name is None:
|