Spaces:
Sleeping
Sleeping
Commit
·
a15bc19
1
Parent(s):
b7cfea3
Update matt_function.py
Browse files- matt_function.py +7 -18
matt_function.py
CHANGED
|
@@ -1,15 +1,5 @@
|
|
| 1 |
-
from
|
| 2 |
-
from
|
| 3 |
-
from langchain.embeddings import OpenAIEmbeddings
|
| 4 |
-
from langchain.vectorstores import Chroma
|
| 5 |
-
|
| 6 |
-
# Import OpenAI as main LLM service
|
| 7 |
-
from langchain.llms import OpenAI
|
| 8 |
-
from langchain.embeddings import OpenAIEmbeddings
|
| 9 |
-
|
| 10 |
-
# Import PDF document loaders...there's other ones as well!
|
| 11 |
-
from langchain.document_loaders import PyPDFLoader
|
| 12 |
-
from langchain.indexes import VectorstoreIndexCreator
|
| 13 |
|
| 14 |
|
| 15 |
|
|
@@ -17,11 +7,10 @@ def create_VSI(files, index): #add vsi and filepaths
|
|
| 17 |
|
| 18 |
pathnames = [file.name for file in files]
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
loaders.append(loader)
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
return
|
|
|
|
| 1 |
+
from llama_index.llms import OpenAI
|
| 2 |
+
from llama_index import VectorStoreIndex, SimpleDirectoryReader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
|
|
|
|
| 7 |
|
| 8 |
pathnames = [file.name for file in files]
|
| 9 |
|
| 10 |
+
documents = SimpleDirectoryReader(input_files=pathnames).load_data()
|
| 11 |
+
|
| 12 |
+
index = VectorStoreIndex.from_documents(documents)
|
|
|
|
| 13 |
|
| 14 |
+
query_engine = index.as_query_engine()
|
| 15 |
|
| 16 |
+
return query_engine, "Upload complete"
|