Spaces:
Sleeping
Sleeping
Update user_guide_sync.py
Browse files- user_guide_sync.py +13 -11
user_guide_sync.py
CHANGED
@@ -14,17 +14,9 @@ from llama_index.llms import OpenAI
|
|
14 |
from llama_index import StorageContext, load_index_from_storage
|
15 |
|
16 |
|
17 |
-
os.environ["OPENAI_API_KEY"]
|
|
|
18 |
|
19 |
-
try:
|
20 |
-
storage_context = StorageContext.from_defaults(persist_dir="llama_index")
|
21 |
-
index = load_index_from_storage(storage_context=storage_context)
|
22 |
-
print("loaded")
|
23 |
-
except:
|
24 |
-
documents = SimpleDirectoryReader("userguid").load_data()
|
25 |
-
index = VectorStoreIndex.from_documents(documents)
|
26 |
-
index.storage_context.persist("llama_index")
|
27 |
-
print("index created")
|
28 |
|
29 |
# URL of the page to scrape
|
30 |
url = 'https://help.storemate.cloud/docs/'
|
@@ -73,4 +65,14 @@ def get_base_links():
|
|
73 |
return "data updated"
|
74 |
|
75 |
def update_user_guide():
|
76 |
-
get_base_links()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
from llama_index import StorageContext, load_index_from_storage
|
15 |
|
16 |
|
17 |
+
#os.environ["OPENAI_API_KEY"]
|
18 |
+
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# URL of the page to scrape
|
22 |
url = 'https://help.storemate.cloud/docs/'
|
|
|
65 |
return "data updated"
|
66 |
|
67 |
def update_user_guide():
|
68 |
+
get_base_links()
|
69 |
+
# try:
|
70 |
+
# storage_context = StorageContext.from_defaults(persist_dir="llama_index")
|
71 |
+
# index = load_index_from_storage(storage_context=storage_context)
|
72 |
+
# print("loaded")
|
73 |
+
# except:
|
74 |
+
documents = SimpleDirectoryReader("user_guide").load_data()
|
75 |
+
index = VectorStoreIndex.from_documents(documents)
|
76 |
+
index.storage_context.persist("llama_index")
|
77 |
+
print("index created")
|
78 |
+
return index
|