Skip to content

Commit

Permalink
web loader fix
Browse files Browse the repository at this point in the history
Changes web loader to the correct output.
  • Loading branch information
pabik committed Jan 17, 2025
1 parent a90b286 commit fddee69
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions application/parser/remote/web_loader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from application.parser.remote.base import BaseRemote
from application.parser.schema.base import Document
from langchain_community.document_loaders import WebBaseLoader
from urllib.parse import urlparse

headers = {
"User-Agent": "Mozilla/5.0",
Expand All @@ -23,10 +25,20 @@ def load_data(self, inputs):
urls = [urls]
documents = []
for url in urls:
# Check if the URL scheme is provided, if not, assume http
if not urlparse(url).scheme:
url = "http://" + url

Check warning on line 30 in application/parser/remote/web_loader.py

View check run for this annotation

Codecov / codecov/patch

application/parser/remote/web_loader.py#L29-L30

Added lines #L29 - L30 were not covered by tests
try:
loader = self.loader([url], header_template=headers)
documents.extend(loader.load())
loaded_docs = loader.load()
for doc in loaded_docs:
documents.append(

Check warning on line 35 in application/parser/remote/web_loader.py

View check run for this annotation

Codecov / codecov/patch

application/parser/remote/web_loader.py#L33-L35

Added lines #L33 - L35 were not covered by tests
Document(
doc.page_content,
extra_info=doc.metadata,
)
)
except Exception as e:
print(f"Error processing URL {url}: {e}")
continue
return documents
return documents

Check warning on line 44 in application/parser/remote/web_loader.py

View check run for this annotation

Codecov / codecov/patch

application/parser/remote/web_loader.py#L44

Added line #L44 was not covered by tests

0 comments on commit fddee69

Please sign in to comment.