mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
path handling
This commit is contained in:
@@ -147,22 +147,23 @@ def check_docs():
|
|||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
vectorstore = "vectors/" + data["docs"]
|
vectorstore = "vectors/" + data["docs"]
|
||||||
base_path = 'https://raw.githubusercontent.com/arc53/DocsHUB/main/'
|
base_path = 'https://raw.githubusercontent.com/arc53/DocsHUB/main/'
|
||||||
#
|
if os.path.exists(vectorstore) or data["docs"] == "default":
|
||||||
if os.path.exists(vectorstore):
|
|
||||||
return {"status": 'exists'}
|
return {"status": 'exists'}
|
||||||
else:
|
else:
|
||||||
r = requests.get(base_path + vectorstore + "index.faiss")
|
r = requests.get(base_path + vectorstore + "index.faiss")
|
||||||
# save to vectors directory
|
|
||||||
# check if the directory exists
|
|
||||||
if not os.path.exists(vectorstore):
|
|
||||||
os.makedirs(vectorstore)
|
|
||||||
|
|
||||||
with open(vectorstore + "index.faiss", "wb") as f:
|
if r.status_code != 200:
|
||||||
f.write(r.content)
|
return {"status": 'null'}
|
||||||
# download the store
|
else:
|
||||||
r = requests.get(base_path + vectorstore + "index.pkl")
|
if not os.path.exists(vectorstore):
|
||||||
with open(vectorstore + "index.pkl", "wb") as f:
|
os.makedirs(vectorstore)
|
||||||
f.write(r.content)
|
with open(vectorstore + "index.faiss", "wb") as f:
|
||||||
|
f.write(r.content)
|
||||||
|
|
||||||
|
# download the store
|
||||||
|
r = requests.get(base_path + vectorstore + "index.pkl")
|
||||||
|
with open(vectorstore + "index.pkl", "wb") as f:
|
||||||
|
f.write(r.content)
|
||||||
|
|
||||||
return {"status": 'loaded'}
|
return {"status": 'loaded'}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user