|
|
@@ -31,9 +31,10 @@ class Chatbot():
|
|
|
# load index
|
|
|
self.ai_storage_context = None
|
|
|
self.ai_index = None
|
|
|
- base_dir = os.path.join(settings.BASE_DIR, 'storage')
|
|
|
+ self.base_dir = os.path.join(settings.BASE_DIR, 'storage')
|
|
|
+ print(self.base_dir)
|
|
|
try:
|
|
|
- self.ai_storage_context = StorageContext.from_defaults(persist_dir=base_dir)
|
|
|
+ self.ai_storage_context = StorageContext.from_defaults(persist_dir=self.base_dir)
|
|
|
self.ai_index = load_index_from_storage(self.ai_storage_context)
|
|
|
except BaseException as error:
|
|
|
# exc_type, exc_obj, exc_tb = sys.exc_info()
|
|
|
@@ -41,7 +42,6 @@ class Chatbot():
|
|
|
# strErro = "ERRO: %s | %s | %s | %s" % (error, exc_type, fname, exc_tb.tb_lineno)
|
|
|
logger.info('Chatbot() init: '+str(error))
|
|
|
pass
|
|
|
- pass
|
|
|
|
|
|
def train (self, chat=None):
|
|
|
status = 400
|
|
|
@@ -115,7 +115,7 @@ class Chatbot():
|
|
|
|
|
|
# save index to disk
|
|
|
if ai_documents:
|
|
|
- self.ai_index.storage_context.persist()
|
|
|
+ self.ai_index.storage_context.persist(persist_dir=self.base_dir)
|
|
|
status = 200
|
|
|
|
|
|
logger.info('Chatbot Training finished | Status '+str(status))
|