id
stringlengths
14
16
text
stringlengths
4
1.28k
source
stringlengths
54
121
2fa1f6e912af-0
Source code for langchain.document_loaders.readthedocs """Loader that loads ReadTheDocs documentation directory dump.""" from pathlib import Path from typing import Any, List, Optional, Tuple, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ReadT...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
2fa1f6e912af-1
`<main id="main-content>`, <`div role="main>`, and `<article role="main">`. You can also define your own html tags by passing custom_html_tag, e.g. `("div", "class=main")`. The loader iterates html tags with the order of custom html tags (if exists) and default html tags. If any of the tags is n...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
2fa1f6e912af-2
except ImportError: raise ImportError( "Could not import python packages. " "Please install it with `pip install beautifulsoup4`. " ) try: _ = BeautifulSoup( "<html><body>Parser builder library test.</body></html>", **kwargs ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
2fa1f6e912af-3
text = self._clean_data(f.read()) metadata = {"source": str(p)} docs.append(Document(page_content=text, metadata=metadata)) return docs def _clean_data(self, data: str) -> str: from bs4 import BeautifulSoup soup = BeautifulSoup(data, **self.bs_kwargs) # defaul...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
2fa1f6e912af-4
if text is not None: text = text.get_text() else: text = "" # trim empty lines return "\n".join([t for t in text.split("\n") if t])
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
d17a061719e3-0
Source code for langchain.document_loaders.twitter """Twitter document loader.""" from __future__ import annotations from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHEC...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
d17a061719e3-1
/getting-started/getting-access-to-the-twitter-api` to get your token. And create a v2 version of the app. """ def __init__( self, auth_handler: Union[OAuthHandler, OAuth2BearerHandler], twitter_users: Sequence[str], number_tweets: Optional[int] = 100, ): self.aut...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
d17a061719e3-2
user = api.get_user(screen_name=username) docs = self._format_tweets(tweets, user) results.extend(docs) return results def _format_tweets( self, tweets: List[Dict[str, Any]], user_info: dict ) -> Iterable[Document]: """Format tweets into a string.""" for t...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
d17a061719e3-3
) -> TwitterTweetLoader: """Create a TwitterTweetLoader from OAuth2 bearer token.""" tweepy = _dependable_tweepy_import() auth = tweepy.OAuth2BearerHandler(oauth2_bearer_token) return cls( auth_handler=auth, twitter_users=twitter_users, number_tweets=n...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
d17a061719e3-4
auth = tweepy.OAuthHandler( access_token=access_token, access_token_secret=access_token_secret, consumer_key=consumer_key, consumer_secret=consumer_secret, ) return cls( auth_handler=auth, twitter_users=twitter_users, nu...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
acdaad712896-0
Source code for langchain.document_loaders.iugu """Loader that fetches data from IUGU""" import json import urllib.request from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import get_from_env, stringify_dict IU...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
acdaad712896-1
def __init__(self, resource: str, api_token: Optional[str] = None) -> None: self.resource = resource api_token = api_token or get_from_env("api_token", "IUGU_API_TOKEN") self.headers = {"Authorization": f"Bearer {api_token}"} def _make_request(self, url: str) -> List[Document]: reque...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
acdaad712896-2
return self._make_request(endpoint) [docs] def load(self) -> List[Document]: return self._get_resource()
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/iugu.html
27d6c2a83a3a-0
Source code for langchain.document_loaders.reddit """Reddit document loader.""" from __future__ import annotations from typing import TYPE_CHECKING, Iterable, List, Optional, Sequence from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader if TYPE_CHECKING: import pra...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
27d6c2a83a3a-1
client_id: str, client_secret: str, user_agent: str, search_queries: Sequence[str], mode: str, categories: Sequence[str] = ["new"], number_posts: Optional[int] = 10, ): self.client_id = client_id self.client_secret = client_secret self.user_age...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
27d6c2a83a3a-2
if self.mode == "subreddit": for search_query in self.search_queries: for category in self.categories: docs = self._subreddit_posts_loader( search_query=search_query, category=category, reddit=reddit ) result...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
27d6c2a83a3a-3
) -> Iterable[Document]: subreddit = reddit.subreddit(search_query) method = getattr(subreddit, category) cat_posts = method(limit=self.number_posts) """Format reddit posts into a string.""" for post in cat_posts: metadata = { "post_subreddit": post.su...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
27d6c2a83a3a-4
method = getattr(user.submissions, category) cat_posts = method(limit=self.number_posts) """Format reddit posts into a string.""" for post in cat_posts: metadata = { "post_subreddit": post.subreddit_name_prefixed, "post_category": category, ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/reddit.html
a1dc0920411c-0
Source code for langchain.document_loaders.azure_blob_storage_container """Loading logic for loading documents from an Azure Blob Storage container.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.azure_blob_storage_file import ( AzureBlobStorageFileLoader...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html
a1dc0920411c-1
except ImportError as exc: raise ValueError( "Could not import azure storage blob python package. " "Please install it with `pip install azure-storage-blob`." ) from exc container = ContainerClient.from_connection_string( conn_str=self.conn_str...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html
fa0e6b2af086-0
Source code for langchain.document_loaders.markdown """Loader that loads Markdown files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredMarkdownLoader(UnstructuredFileLoader): """Loader that uses unstructured to load markdown files.""" ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html
fa0e6b2af086-1
raise ValueError( f"You are on unstructured version {__unstructured_version__}. " "Partitioning markdown files is only supported in unstructured>=0.4.16." ) return partition_md(filename=self.file_path, **self.unstructured_kwargs)
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/markdown.html
90ad658aa9fc-0
Source code for langchain.document_loaders.stripe """Loader that fetches data from Stripe""" import json import urllib.request from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import get_from_env, stringify_dic...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
90ad658aa9fc-1
[docs]class StripeLoader(BaseLoader): """Loader that fetches data from Stripe.""" def __init__(self, resource: str, access_token: Optional[str] = None) -> None: self.resource = resource access_token = access_token or get_from_env( "access_token", "STRIPE_ACCESS_TOKEN" ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
90ad658aa9fc-2
endpoint = STRIPE_ENDPOINTS.get(self.resource) if endpoint is None: return [] return self._make_request(endpoint) [docs] def load(self) -> List[Document]: return self._get_resource()
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/stripe.html
1da3e49089aa-0
Source code for langchain.document_loaders.ifixit """Loader that loads iFixit data.""" from typing import List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.web_base import WebBaseLoader IFIXIT_BASE_URL =...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-1
and wikis from devices on iFixit using their open APIs and web scraping. """ def __init__(self, web_path: str): """Initialize with web path.""" if not web_path.startswith("https://www.ifixit.com"): raise ValueError("web path must start with 'https://www.ifixit.com'") path = w...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-2
self.page_type = pieces[0] if pieces[0] != "Teardown" else "Guide" if self.page_type == "Guide" or self.page_type == "Answers": self.id = pieces[2] else: self.id = pieces[1] self.web_path = web_path [docs] def load(self) -> List[Document]: if self.page_type == ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-3
res = requests.get( IFIXIT_BASE_URL + "/suggest/" + query + "?doctypes=" + doc_type ) if res.status_code != 200: raise ValueError( 'Could not load suggestions for "' + query + '"\n' + res.json() ) data = res.json() results = data["resul...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-4
) -> List[Document]: loader = WebBaseLoader(self.web_path if url_override is None else url_override) soup = loader.scrape() output = [] title = soup.find("h1", "post-title").text output.append("# " + title) output.append(soup.select_one(".post-content .post-text").text.st...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-5
else: output.append("\n### Other Answer") output += [ a.text.strip() for a in answer.select(".post-content .post-text") ] output.append("\n") text = "\n".join(output).strip() metadata = {"source": self.web_path, "title": title} ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-6
[ data[key] for key in ["title", "description", "contents_raw"] if key in data ] ).strip() metadata = {"source": self.web_path, "title": data["title"]} documents.append(Document(page_content=text, metadata=metadata)) if include_...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-7
else: url = url_override res = requests.get(url) if res.status_code != 200: raise ValueError( "Could not load guide: " + self.web_path + "\n" + res.json() ) data = res.json() doc_parts = ["# " + data["title"], data["introduction_raw"]] ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1da3e49089aa-8
for part in data["parts"]: doc_parts.append("\n - " + part["text"]) for row in data["steps"]: doc_parts.append( "\n\n## " + ( row["title"] if row["title"] != "" else "Step {}".format(row["orde...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1e9f6243de05-0
Source code for langchain.document_loaders.notiondb """Notion DB loader for langchain""" from typing import Any, Dict, List, Optional import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader NOTION_BASE_URL = "https://api.notion.com/v1" DATABASE_URL = NOTIO...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
1e9f6243de05-1
""" def __init__( self, integration_token: str, database_id: str, request_timeout_sec: Optional[int] = 10, ) -> None: """Initialize with parameters.""" if not integration_token: raise ValueError("integration_token must be provided") if not data...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
1e9f6243de05-2
List[Document]: List of documents. """ page_summaries = self._retrieve_page_summaries() return list(self.load_page(page_summary) for page_summary in page_summaries) def _retrieve_page_summaries( self, query_dict: Dict[str, Any] = {"page_size": 100} ) -> List[Dict[str, Any]]: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
1e9f6243de05-3
return pages [docs] def load_page(self, page_summary: Dict[str, Any]) -> Document: """Read a page.""" page_id = page_summary["id"] # load properties as metadata metadata: Dict[str, Any] = {} for prop_name, prop_data in page_summary["properties"].items(): prop_type ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
1e9f6243de05-4
if prop_data["multi_select"] else [] ) elif prop_type == "url": value = prop_data["url"] else: value = None metadata[prop_name.lower()] = value metadata["id"] = page_id return Document(page_content=se...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
1e9f6243de05-5
continue cur_result_text_arr: List[str] = [] for rich_text in result_obj["rich_text"]: if "text" in rich_text: cur_result_text_arr.append( "\t" * num_tabs + rich_text["text"]["content"] ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
1e9f6243de05-6
method, url, headers=self.headers, json=query_dict, timeout=self.request_timeout_sec, ) res.raise_for_status() return res.json()
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
205a4f50c1b8-0
Source code for langchain.document_loaders.bibtex import logging import re from pathlib import Path from typing import Any, Iterator, List, Mapping, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.bibtex import BibtexparserWrapper...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
205a4f50c1b8-1
file_path: str, *, parser: Optional[BibtexparserWrapper] = None, max_docs: Optional[int] = None, max_content_chars: Optional[int] = 4_000, load_extra_metadata: bool = False, file_pattern: str = r"[^:]+\.pdf", ): """Initialize the BibtexLoader. Args: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
205a4f50c1b8-2
def _load_entry(self, entry: Mapping[str, Any]) -> Optional[Document]: import fitz parent_dir = Path(self.file_path).parent # regex is useful for Zotero flavor bibtex files file_names = self.file_regex.findall(entry.get("file", "")) if not file_names: return None ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
205a4f50c1b8-3
return Document( page_content=content, metadata=metadata, ) [docs] def lazy_load(self) -> Iterator[Document]: """Load bibtex file using bibtexparser and get the article texts plus the article metadata. See https://bibtexparser.readthedocs.io/en/master/ ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
205a4f50c1b8-4
doc = self._load_entry(entry) if doc: yield doc [docs] def load(self) -> List[Document]: """Load bibtex file documents from the given bibtex file path. See https://bibtexparser.readthedocs.io/en/master/ Args: file_path: the path to the bibtex file ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/bibtex.html
08768ba025bf-0
Source code for langchain.document_loaders.slack_directory """Loader for documents from a Slack export.""" import json import zipfile from pathlib import Path from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class Slack...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
08768ba025bf-1
self.workspace_url = workspace_url self.channel_id_map = self._get_channel_id_map(self.zip_path) @staticmethod def _get_channel_id_map(zip_path: Path) -> Dict[str, str]: """Get a dictionary mapping channel names to their respective IDs.""" with zipfile.ZipFile(zip_path, "r") as zip_file:...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
08768ba025bf-2
channel_name = Path(channel_path).parent.name if not channel_name: continue if channel_path.endswith(".json"): messages = self._read_json(zip_file, channel_path) for message in messages: document = self._...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
08768ba025bf-3
Args: message (dict): A message in the form of a dictionary. channel_name (str): The name of the channel the message belongs to. Returns: Document: A Document object representing the message. """ text = message.get("text", "") metadata = self._get_mess...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
08768ba025bf-4
"timestamp": timestamp, "user": user, } def _get_message_source(self, channel_name: str, user: str, timestamp: str) -> str: """ Get the message source as a string. Args: channel_name (str): The name of the channel the message belongs to. user (str)...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
c86265d162a0-0
Source code for langchain.document_loaders.merge from typing import Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class MergedDataLoader(BaseLoader): """Merge documents from a list of loaders""" def __init__(self, loaders: List): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/merge.html
c288a836e506-0
Source code for langchain.document_loaders.hn """Loader that loads HN.""" from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class HNLoader(WebBaseLoader): """Load Hacker News data from either main page results or the com...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
c288a836e506-1
return self.load_results(soup_info) [docs] def load_comments(self, soup_info: Any) -> List[Document]: """Load comments from a HN post.""" comments = soup_info.select("tr[class='athing comtr']") title = soup_info.select_one("tr[id='pagespace']").get("title") return [ Docume...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
c288a836e506-2
link = lineItem.find("span", {"class": "titleline"}).find("a").get("href") title = lineItem.find("span", {"class": "titleline"}).text.strip() metadata = { "source": self.web_path, "title": title, "link": link, "ranking": ranking, ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/hn.html
404cf6d1cbc8-0
Source code for langchain.document_loaders.figma """Loader that loads Figma files json dump.""" import json import urllib.request from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utils import stringify_dict [docs]class Fi...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/figma.html
404cf6d1cbc8-1
) return api_url def _get_figma_file(self) -> Any: """Get Figma file from Figma REST API.""" headers = {"X-Figma-Token": self.access_token} request = urllib.request.Request( self._construct_figma_api_url(), headers=headers ) with urllib.request.urlopen(req...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/figma.html
4ab6e9e87f71-0
Source code for langchain.document_loaders.roam """Loader that loads Roam directory dump.""" from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class RoamLoader(BaseLoader): """Loader that loads Roam files fr...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html
86c56019501c-0
Source code for langchain.document_loaders.mhtml """Loader to load MHTML files, enriching metadata with page title.""" import email import logging from typing import Dict, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__nam...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
86c56019501c-1
except ImportError: raise ValueError( "beautifulsoup4 package not found, please install it with " "`pip install beautifulsoup4`" ) self.file_path = file_path self.open_encoding = open_encoding if bs_kwargs is None: bs_kwargs = {...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
86c56019501c-2
html = part.get_payload(decode=True).decode() soup = BeautifulSoup(html, **self.bs_kwargs) text = soup.get_text(self.get_text_separator) if soup.title: title = str(soup.title.string) else: tit...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mhtml.html
e0616031f9e1-0
Source code for langchain.document_loaders.xml """Loader that loads Microsoft Excel files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredXMLLoader(UnstructuredFileLoader): """Loader that ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/xml.html
65c3bedaf6e2-0
Source code for langchain.document_loaders.obsidian """Loader that loads Obsidian directory dump.""" import re from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ObsidianLoader(BaseLoader): """Loader th...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
65c3bedaf6e2-1
"""Parse front matter metadata from the content and return it as a dict.""" if not self.collect_metadata: return {} match = self.FRONT_MATTER_REGEX.search(content) front_matter = {} if match: lines = match.group(1).split("\n") for line in lines: ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
65c3bedaf6e2-2
"""Load documents.""" ps = list(Path(self.file_path).glob("**/*.md")) docs = [] for p in ps: with open(p, encoding=self.encoding) as f: text = f.read() front_matter = self._parse_front_matter(text) text = self._remove_front_matter(text) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
998152b09dc7-0
Source code for langchain.document_loaders.mediawikidump """Load Data from a MediaWiki dump xml.""" from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class MWDumpLoader(BaseLoader): """ Load MediaWiki dump from XML fil...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
998152b09dc7-1
:type file_path: str :param encoding: Charset encoding, defaults to "utf8" :type encoding: str, optional """ def __init__(self, file_path: str, encoding: Optional[str] = "utf8"): """Initialize with file path.""" self.file_path = file_path self.encoding = encoding [docs] def lo...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
998152b09dc7-2
metadata = {"source": page.title} docs.append(Document(page_content=text, metadata=metadata)) return docs
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/mediawikidump.html
b8acc8b50fa2-0
Source code for langchain.document_loaders.recursive_url_loader from typing import Iterator, List, Optional, Set from urllib.parse import urlparse import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class RecursiveUrlLoader(BaseLoader): """Lo...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/recursive_url_loader.html
b8acc8b50fa2-1
except ImportError: raise ImportError( "The BeautifulSoup package is required for the RecursiveUrlLoader." ) # Construct the base and parent URLs parsed_url = urlparse(url) base_url = f"{parsed_url.scheme}://{parsed_url.netloc}" parent_url = "/".jo...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/recursive_url_loader.html
b8acc8b50fa2-2
): return visited # Get all links that are relative to the root of the website response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") all_links = [link.get("href") for link in soup.find_all("a")] # Extract only the links that are children of t...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/recursive_url_loader.html
b8acc8b50fa2-3
# Check all unvisited links if link not in visited: visited.add(link) # If the link is a directory (w/ children) then visit it if link.endswith("/"): visited.update(self.get_child_links_recursive(link, visited)) return visited [docs...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/recursive_url_loader.html
2d3aff8eb1d6-0
Source code for langchain.document_loaders.json_loader """Loader that loads data from JSON.""" import json from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class JSONLoader...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
2d3aff8eb1d6-1
jq_schema: str, content_key: Optional[str] = None, metadata_func: Optional[Callable[[Dict, Dict], Dict]] = None, text_content: bool = True, ): """Initialize the JSONLoader. Args: file_path (Union[str, Path]): The path to the JSON file. jq_schema (str):...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
2d3aff8eb1d6-2
string format, default to True """ try: import jq # noqa:F401 except ImportError: raise ImportError( "jq package not found, please install it with `pip install jq`" ) self.file_path = Path(file_path).resolve() self._jq_schema =...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
2d3aff8eb1d6-3
self._validate_content_key(data) docs = [] for i, sample in enumerate(data, 1): metadata = dict( source=str(self.file_path), seq_num=i, ) text = self._get_text(sample=sample, metadata=metadata) docs.append(Document(page_cont...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
2d3aff8eb1d6-4
else: content = sample if self._text_content and not isinstance(content, str): raise ValueError( f"Expected page_content is string, got {type(content)} instead. \ Set `text_content=False` if the desired input for \ `page_content` is...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
2d3aff8eb1d6-5
raise ValueError( f"Expected the jq schema to result in a list of objects (dict), \ so sample must be a dict but got `{type(sample)}`" ) if sample.get(self._content_key) is None: raise ValueError( f"Expected the jq schema to result in a...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/json_loader.html
b1f5b500df95-0
Source code for langchain.document_loaders.trello """Loader that loads cards from Trello""" from __future__ import annotations from typing import TYPE_CHECKING, Any, List, Literal, Optional, Tuple from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.util...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-1
extra_metadata: Tuple[str, ...] = ("due_date", "labels", "list", "closed"), ): """Initialize Trello loader. Args: client: Trello API client. board_name: The name of the Trello board. include_card_name: Whether to include the name of the card in the document. ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-2
self.board_name = board_name self.include_card_name = include_card_name self.include_comments = include_comments self.include_checklist = include_checklist self.extra_metadata = extra_metadata self.card_filter = card_filter [docs] @classmethod def from_credentials( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-3
TRELLO_TOKEN. include_card_name: Whether to include the name of the card in the document. include_comments: Whether to include the comments on the card in the document. include_checklist: Whether to include the checklist on the card in the document. ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-4
) from ex api_key = api_key or get_from_env("api_key", "TRELLO_API_KEY") token = token or get_from_env("token", "TRELLO_TOKEN") client = TrelloClient(api_key=api_key, token=token) return cls(client, board_name, **kwargs) [docs] def load(self) -> List[Document]: """Loads all ca...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-5
) from ex board = self._get_board() # Create a dictionary with the list IDs as keys and the list names as values list_dict = {list_item.id: list_item.name for list_item in board.list_lists()} # Get Cards on the board cards = board.get_cards(card_filter=self.card_filter) r...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-6
from bs4 import BeautifulSoup # type: ignore text_content = "" if self.include_card_name: text_content = card.name + "\n" if card.description.strip(): text_content += BeautifulSoup(card.description, "lxml").get_text() if self.include_checklist: # Get ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
b1f5b500df95-7
for comment in card.comments ] text_content += "Comments:" + "\n".join(comments) # Default metadata fields metadata = { "title": card.name, "id": card.id, "url": card.url, } # Extra metadata fields. Card object is not subscripta...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/trello.html
84697635f46f-0
Source code for langchain.document_loaders.acreom """Loader that loads acreom vault from a directory.""" import re from pathlib import Path from typing import Iterator, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class AcreomLoader(BaseLoader): ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/acreom.html
84697635f46f-1
if not self.collect_metadata: return {} match = self.FRONT_MATTER_REGEX.search(content) front_matter = {} if match: lines = match.group(1).split("\n") for line in lines: if ":" in line: key, value = line.split(":", 1) ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/acreom.html
84697635f46f-2
# do not contribute to the context of current document content = re.sub("\s*-\s\[\s\]\s.*|\s*\[\s\]\s.*", "", content) # rm tasks content = re.sub("#", "", content) # rm hashtags content = re.sub("\[\[.*?\]\]", "", content) # rm doclinks return content [docs] def lazy_load(self) ->...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/acreom.html
84697635f46f-3
"source": str(p.name), "path": str(p), **front_matter, } yield Document(page_content=text, metadata=metadata) [docs] def load(self) -> List[Document]: return list(self.lazy_load())
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/acreom.html
4f5cacd0e13c-0
Source code for langchain.document_loaders.image """Loader that loads image files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredImageLoader(UnstructuredFileLoader): """Loader that uses unstructured to load image files, such as PNGs and...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/image.html
c6e1b2c131ae-0
Source code for langchain.document_loaders.wikipedia from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.utilities.wikipedia import WikipediaAPIWrapper [docs]class WikipediaLoader(BaseLoader): """Loads a query resul...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html
c6e1b2c131ae-1
Args: query (str): The query string to search on Wikipedia. lang (str, optional): The language code for the Wikipedia language edition. Defaults to "en". load_max_docs (int, optional): The maximum number of documents to load. Defaults to 100. ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html
c6e1b2c131ae-2
""" Loads the query result from Wikipedia into a list of Documents. Returns: List[Document]: A list of Document objects representing the loaded Wikipedia pages. """ client = WikipediaAPIWrapper( lang=self.lang, top_k_results=self.load_m...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/wikipedia.html
81c42cbcf0ef-0
Source code for langchain.document_loaders.imsdb """Loader that loads IMSDb.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class IMSDbLoader(WebBaseLoader): """Loader that loads IMSDb webpages.""" [docs] def load(se...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html
07b29e71010a-0
Source code for langchain.document_loaders.excel """Loader that loads Microsoft Excel files.""" from typing import Any, List from langchain.document_loaders.unstructured import ( UnstructuredFileLoader, validate_unstructured_version, ) [docs]class UnstructuredExcelLoader(UnstructuredFileLoader): """Loader t...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/excel.html
4db1aa5fc4dc-0
Source code for langchain.document_loaders.unstructured """Loader that uses unstructured to load files.""" import collections from abc import ABC, abstractmethod from typing import IO, Any, Dict, List, Sequence, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoade...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
4db1aa5fc4dc-1
unstructured_version_tuple = tuple( [int(x) for x in _unstructured_version.split(".")] ) return unstructured_version_tuple >= min_version_tuple def validate_unstructured_version(min_unstructured_version: str) -> None: """Raises an error if the unstructured version does not exceed the specified m...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
4db1aa5fc4dc-2
except ImportError: raise ValueError( "unstructured package not found, please install it with " "`pip install unstructured`" ) _valid_modes = {"single", "elements", "paged"} if mode not in _valid_modes: raise ValueError( ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html
4db1aa5fc4dc-3
"""Load file.""" elements = self._get_elements() if self.mode == "elements": docs: List[Document] = list() for element in elements: metadata = self._get_metadata() # NOTE(MthwRobinson) - the attribute check is for backward compatibility ...
https://api.python.langchain.com/en/latest/_modules/langchain/document_loaders/unstructured.html