improved error handling
This commit is contained in:
parent
a36eeb368e
commit
87727b3d1e
|
@ -7,3 +7,4 @@ langchain
|
|||
pathlib
|
||||
unstructured
|
||||
markdown
|
||||
requests
|
|
@ -6,6 +6,7 @@ from langchain_community.embeddings import OllamaEmbeddings
|
|||
from langchain_community.vectorstores import Chroma
|
||||
from langchain_community.chat_models import ChatOllama
|
||||
from langchain.chains import RetrievalQA
|
||||
import requests
|
||||
|
||||
|
||||
|
||||
|
@ -40,10 +41,13 @@ class Rag:
|
|||
def get_file(self, file_path):
|
||||
# Check if the file path starts with 'https://'
|
||||
if file_path.startswith('https://'):
|
||||
try:
|
||||
loader = WebBaseLoader(file_path)
|
||||
data = loader.load()
|
||||
if data is None:
|
||||
return False
|
||||
except requests.exceptions.SSLError:
|
||||
return False
|
||||
else:
|
||||
file_type = file_path.split(".")[-1]
|
||||
try:
|
||||
|
@ -61,8 +65,7 @@ class Rag:
|
|||
loader = PyPDFLoader(file_path=file_path)
|
||||
data = loader.load_and_split()
|
||||
case _:
|
||||
loader = WebBaseLoader(file_path)
|
||||
data = loader.load()
|
||||
return False
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue