Add URLComponent to load a URL
This commit is contained in:
parent
56af9280b5
commit
698fa6bf90
1 changed files with 26 additions and 0 deletions
26
src/backend/langflow/components/data/URL.py
Normal file
26
src/backend/langflow/components/data/URL.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
from langchain_community.document_loaders.url import UnstructuredURLLoader
|
||||||
|
|
||||||
|
from langflow import CustomComponent
|
||||||
|
from langflow.schema import Record
|
||||||
|
|
||||||
|
|
||||||
|
class URLComponent(CustomComponent):
|
||||||
|
display_name = "URL"
|
||||||
|
description = "Load a URL."
|
||||||
|
|
||||||
|
def build_config(self) -> Dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"urls": {"display_name": "URL"},
|
||||||
|
}
|
||||||
|
|
||||||
|
async def build(
|
||||||
|
self,
|
||||||
|
urls: list[str],
|
||||||
|
) -> Optional[Record]:
|
||||||
|
|
||||||
|
loader = UnstructuredURLLoader(urls=urls)
|
||||||
|
docs = loader.load()
|
||||||
|
records = self.to_records(docs)
|
||||||
|
return records
|
||||||
Loading…
Add table
Add a link
Reference in a new issue