id
stringlengths
14
16
text
stringlengths
31
3.14k
source
stringlengths
58
124
85a93ca3ea2a-3
Returns: Folder path. """ # Get the course name course_name = soup.find("span", {"id": "crumb_1"}) if course_name is None: raise ValueError("No course name found.") course_name = course_name.text.strip() # Prepare the folder path course_nam...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
85a93ca3ea2a-4
if content_list is None: raise ValueError("No content list found.") content_list: BeautifulSoup # type: ignore # Get all attachments attachments = [] for attachment in content_list.find_all("ul", {"class": "attachments"}): attachment: Tag # type: ignore ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
85a93ca3ea2a-5
"""Get all relative paths in the navbar.""" relative_paths = [] course_menu = soup.find("ul", {"class": "courseMenu"}) if course_menu is None: raise ValueError("No course menu found.") for link in course_menu.find_all("a"): href = link.get("href") if h...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
85a93ca3ea2a-6
"""Parse the filename from a url. Args: url: Url to parse the filename from. Returns: The filename. Raises: ValueError: If the filename could not be parsed. """ filename_matches = re.search(r"filename%2A%3DUTF-8%27%27(.+)", url) if file...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blackboard.html
ae7cabe61274-0
Source code for langchain.document_loaders.git import os from typing import Callable, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class GitLoader(BaseLoader): """Loads files from a Git repository into a list of documents. Repositor...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
ae7cabe61274-1
raise ValueError(f"Path {self.repo_path} does not exist") elif self.clone_url: repo = Repo.clone_from(self.clone_url, self.repo_path) repo.git.checkout(self.branch) else: repo = Repo(self.repo_path) repo.git.checkout(self.branch) docs: List[Documen...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
ae7cabe61274-2
return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/git.html
6ed6fa4c085b-0
Source code for langchain.document_loaders.blockchain import os import re from enum import Enum from typing import List import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader class BlockchainType(Enum): ETH_MAINNET = "eth-mainnet" ETH_GOERLI = "et...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
6ed6fa4c085b-1
raise ValueError("Alchemy API key not provided.") if not re.match(r"^0x[a-fA-F0-9]{40}$", self.contract_address): raise ValueError(f"Invalid contract address {self.contract_address}") [docs] def load(self) -> List[Document]: url = ( f"https://{self.blockchainType}.g.alchemy.co...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/blockchain.html
044b3f7ad14c-0
Source code for langchain.document_loaders.facebook_chat """Loader that loads Facebook chat json dump.""" import datetime import json from pathlib import Path from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(row: dict) -...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
044b3f7ad14c-1
df_normalized_messages = pd.DataFrame(normalized_messages) # Only keep plain text messages # (no services, nor links, hashtags, code, bold ...) df_filtered = df_normalized_messages[ (df_normalized_messages.content.apply(lambda x: type(x) == str)) ] df_filtered = df_fi...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/facebook_chat.html
4546b7ca0dc6-0
Source code for langchain.document_loaders.diffbot """Loader that uses Diffbot to load webpages in text format.""" import logging from typing import Any, List import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__name__) [doc...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/diffbot.html
4546b7ca0dc6-1
return response.json() if response.ok else {} [docs] def load(self) -> List[Document]: """Extract text from Diffbot on all the URLs and return Document instances""" docs: List[Document] = list() for url in self.urls: try: data = self._get_diffbot_data(url) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/diffbot.html
55366b47236a-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/image.html
51276589e00a-0
Source code for langchain.document_loaders.duckdb_loader from typing import Dict, List, Optional, cast from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class DuckDBLoader(BaseLoader): """Loads a query result from DuckDB into a list of documents. Each ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html
51276589e00a-1
"Please install it with `pip install duckdb`." ) docs = [] with duckdb.connect( database=self.database, read_only=self.read_only, config=self.config ) as con: query_result = con.execute(self.query) results = query_result.fetchall() desc...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/duckdb_loader.html
9291fb49550e-0
Source code for langchain.document_loaders.notion """Loader that loads Notion 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 NotionDirectoryLoader(BaseLoader): """Loader that load...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notion.html
f8cd1481e80f-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
f8cd1481e80f-1
def _remove_front_matter(self, content: str) -> str: """Remove front matter metadata from the given content.""" if not self.collect_metadata: return content return self.FRONT_MATTER_REGEX.sub("", content) [docs] def load(self) -> List[Document]: """Load documents.""" ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/obsidian.html
af70b8e8d9f5-0
Source code for langchain.document_loaders.azure_blob_storage_file """Loading logic for loading documents from an Azure Blob Storage file.""" import os import tempfile from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_file.html
af70b8e8d9f5-1
os.makedirs(os.path.dirname(file_path), exist_ok=True) with open(f"{file_path}", "wb") as file: blob_data = client.download_blob() blob_data.readinto(file) loader = UnstructuredFileLoader(file_path) return loader.load() By Harrison Chase © C...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_file.html
3216c3e931e2-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
3216c3e931e2-1
"""Load tweets.""" tweepy = _dependable_tweepy_import() api = tweepy.API(self.auth, parser=tweepy.parsers.JSONParser()) results: List[Document] = [] for username in self.twitter_users: tweets = api.user_timeline(screen_name=username, count=self.number_tweets) user...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
3216c3e931e2-2
return cls( auth_handler=auth, twitter_users=twitter_users, number_tweets=number_tweets, ) [docs] @classmethod def from_secrets( cls, access_token: str, access_token_secret: str, consumer_key: str, consumer_secret: str, t...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/twitter.html
a09d6a09c0e9-0
Source code for langchain.document_loaders.powerpoint """Loader that loads powerpoint files.""" import os from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredPowerPointLoader(UnstructuredFileLoader): """Loader that uses unstructured to load powe...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/powerpoint.html
a09d6a09c0e9-1
) if is_ppt: from unstructured.partition.ppt import partition_ppt return partition_ppt(filename=self.file_path, **self.unstructured_kwargs) else: from unstructured.partition.pptx import partition_pptx return partition_pptx(filename=self.file_path, **self.u...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/powerpoint.html
d1278cb61a60-0
Source code for langchain.document_loaders.azlyrics """Loader that loads AZLyrics.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class AZLyricsLoader(WebBaseLoader): """Loader that loads AZLyrics webpages.""" [docs] ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azlyrics.html
f69391bf857c-0
Source code for langchain.document_loaders.gcs_directory """Loading logic for loading documents from an GCS directory.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.gcs_file import GCSFileLoader [docs]cl...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_directory.html
f69391bf857c-1
return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gcs_directory.html
567cd7f2ea83-0
Source code for langchain.document_loaders.csv_loader from csv import DictReader from typing import Dict, List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class CSVLoader(BaseLoader): """Loads a CSV file into a list of documents. Each d...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
567cd7f2ea83-1
"quotechar": '"', } else: self.csv_args = csv_args [docs] def load(self) -> List[Document]: docs = [] with open(self.file_path, newline="", encoding=self.encoding) as csvfile: csv = DictReader(csvfile, **self.csv_args) # type: ignore for i, row...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/csv_loader.html
57da1f613fb0-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
57da1f613fb0-1
except KeyError: return {} [docs] def load(self) -> List[Document]: """Load and return documents from the Slack directory dump.""" docs = [] with zipfile.ZipFile(self.zip_path, "r") as zip_file: for channel_path in zip_file.namelist(): channel_name ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
57da1f613fb0-2
return Document( page_content=text, metadata=metadata, ) def _get_message_metadata(self, message: dict, channel_name: str) -> dict: """Create and return metadata for a given message and channel.""" timestamp = message.get("ts", "") user = message.get("user", "...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/slack_directory.html
8d0f1ad67d4b-0
Source code for langchain.document_loaders.notiondb """Notion DB loader for langchain""" from typing import Any, Dict, List 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 = NOTION_BASE_URL...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
8d0f1ad67d4b-1
} [docs] def load(self) -> List[Document]: """Load documents from the Notion database. Returns: List[Document]: List of documents. """ page_ids = self._retrieve_page_ids() return list(self.load_page(page_id) for page_id in page_ids) def _retrieve_page_ids( ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
8d0f1ad67d4b-2
if prop_type == "rich_text": value = ( prop_data["rich_text"][0]["plain_text"] if prop_data["rich_text"] else None ) elif prop_type == "title": value = ( prop_data["title"][0]["pla...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
8d0f1ad67d4b-3
cur_result_text_arr.append( "\t" * num_tabs + rich_text["text"]["content"] ) if result["has_children"]: children_text = self._load_blocks( result["id"], num_tabs=num_tabs + 1 ) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/notiondb.html
d2d7b5c9eaea-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 from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class ReadTheDocsLoader(B...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
d2d7b5c9eaea-1
if len(text) == 0: text = soup.find_all("div", {"role": "main"}) if len(text) != 0: text = text[0].get_text() else: text = "" return "\n".join([t for t in text.split("\n") if t]) docs = [] for p in Path(self.file_path).r...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/readthedocs.html
db701136bdcd-0
Source code for langchain.document_loaders.gutenberg """Loader that loads .txt web files.""" from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class GutenbergLoader(BaseLoader): """Loader that uses urllib to load .txt web files.""" ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gutenberg.html
9e340a59fff1-0
Source code for langchain.document_loaders.googledrive """Loader that loads data from Google Drive.""" # Prerequisites: # 1. Create a Google Cloud project # 2. Enable the Google Drive API: # https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com # 3. Authorize credentials for desktop app: # htt...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-1
document_ids: Optional[List[str]] = None file_ids: Optional[List[str]] = None recursive: bool = False @root_validator def validate_folder_id_or_document_ids( cls, values: Dict[str, Any] ) -> Dict[str, Any]: """Validate that either folder_id or document_ids is set, but not both.""" ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-2
from google.oauth2 import service_account from google.oauth2.credentials import Credentials from google_auth_oauthlib.flow import InstalledAppFlow except ImportError: raise ImportError( "You must run" "`pip install --upgrade " "...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-3
creds = self._load_credentials() sheets_service = build("sheets", "v4", credentials=creds) spreadsheet = sheets_service.spreadsheets().get(spreadsheetId=id).execute() sheets = spreadsheet.get("sheets", []) documents = [] for sheet in sheets: sheet_name = sheet["proper...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-4
return documents def _load_document_from_id(self, id: str) -> Document: """Load a document from an ID.""" from io import BytesIO from googleapiclient.discovery import build from googleapiclient.errors import HttpError from googleapiclient.http import MediaIoBaseDownload ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-5
from googleapiclient.discovery import build creds = self._load_credentials() service = build("drive", "v3", credentials=creds) files = self._fetch_files_recursive(service, folder_id) returns = [] for file in files: if file["mimeType"] == "application/vnd.google-apps.d...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-6
) .execute() ) files = results.get("files", []) returns = [] for file in files: if file["mimeType"] == "application/vnd.google-apps.folder": if self.recursive: returns.extend(self._fetch_files_recursive(service, file["id"])) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
9e340a59fff1-7
content = fh.getvalue() from PyPDF2 import PdfReader pdf_reader = PdfReader(BytesIO(content)) return [ Document( page_content=page.extract_text(), metadata={ "source": f"https://drive.google.com/file/d/{id}/view", ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/googledrive.html
ae68c038b487-0
Source code for langchain.document_loaders.gitbook """Loader that loads GitBook.""" from typing import Any, List, Optional from urllib.parse import urljoin, urlparse from langchain.docstore.document import Document from langchain.document_loaders.web_base import WebBaseLoader [docs]class GitbookLoader(WebBaseLoader): ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
ae68c038b487-1
else: web_paths = web_page super().__init__(web_paths) self.load_all_paths = load_all_paths self.content_selector = content_selector [docs] def load(self) -> List[Document]: """Fetch text from one single GitBook page.""" if self.load_all_paths: soup_inf...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
ae68c038b487-2
title = title_if_exists.text if title_if_exists else "" metadata = {"source": custom_url or self.web_path, "title": title} return Document(page_content=content, metadata=metadata) def _get_paths(self, soup: Any) -> List[str]: """Fetch all relative paths in the navbar.""" return [urlp...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/gitbook.html
db484fc02657-0
Source code for langchain.document_loaders.dataframe """Load from Dataframe object""" from typing import Any, List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class DataFrameLoader(BaseLoader): """Load Pandas DataFrames.""" def __init__(self, dat...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/dataframe.html
db484fc02657-1
return result By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/dataframe.html
5229845c7e21-0
Source code for langchain.document_loaders.text from typing import List, Optional from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader [docs]class TextLoader(BaseLoader): """Load text files.""" def __init__(self, file_path: str, encoding: Optional[str] = None):...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/text.html
08667f8c168b-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 =...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
08667f8c168b-1
raise ValueError( "web path must start with /Device, /Guide, /Teardown or /Answers" ) pieces = [x for x in path.split("/") if x] """Teardowns are just guides by a different name""" self.page_type = pieces[0] if pieces[0] != "Teardown" else "Guide" if self.page...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
08667f8c168b-2
) data = res.json() results = data["results"] output = [] for result in results: try: loader = IFixitLoader(result["url"]) if loader.page_type == "Device": output += loader.load_device(include_guides=False) e...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
08667f8c168b-3
output.append("\n### Most Helpful Answer") 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() metada...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
08667f8c168b-4
for guide_url in guide_urls: documents.append(IFixitLoader(guide_url).load()[0]) return documents [docs] def load_guide(self, url_override: Optional[str] = None) -> List[Document]: if url_override is None: url = IFIXIT_BASE_URL + "/guides/" + self.id else: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
08667f8c168b-5
doc_parts.append( "\n\n## " + ( row["title"] if row["title"] != "" else "Step {}".format(row["orderby"]) ) ) for line in row["lines"]: doc_parts.append(line["text_raw"]) ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/ifixit.html
1c8ab4f7e063-0
Source code for langchain.document_loaders.confluence """Load Data from a Confluence Space""" import logging from typing import Any, Callable, List, Optional, Union from tenacity import ( before_sleep_log, retry, stop_after_attempt, wait_exponential, ) from langchain.docstore.document import Document fr...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-1
loader = ConfluenceLoader( url="https://yoursite.atlassian.com/wiki", username="me", api_key="12345" ) documents = loader.load(space_key="SPACE",limit=50) :param url: _description_ :type url: str :param api_key: _description_, defaults ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-2
username: Optional[str] = None, oauth2: Optional[dict] = None, cloud: Optional[bool] = True, number_of_retries: Optional[int] = 3, min_retry_seconds: Optional[int] = 2, max_retry_seconds: Optional[int] = 10, confluence_kwargs: Optional[dict] = None, ): conflue...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-3
) [docs] @staticmethod def validate_init_args( url: Optional[str] = None, api_key: Optional[str] = None, username: Optional[str] = None, oauth2: Optional[dict] = None, ) -> Union[List, None]: """Validates proper combinations of init arguments""" errors = [] ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-4
self, space_key: Optional[str] = None, page_ids: Optional[List[str]] = None, label: Optional[str] = None, cql: Optional[str] = None, include_attachments: bool = False, include_comments: bool = False, limit: Optional[int] = 50, max_pages: Optional[int] = 10...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-5
:return: _description_ :rtype: List[Document] """ if not space_key and not page_ids and not label and not cql: raise ValueError( "Must specify at least one among `space_key`, `page_ids`," "`label`, `cql` parameters." ) docs = [] ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-6
reraise=True, stop=stop_after_attempt( self.number_of_retries # type: ignore[arg-type] ), wait=wait_exponential( multiplier=1, # type: ignore[arg-type] min=self.min_retry_seconds, # typ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-7
just checking for the presence of a `next` key in the response like this page would have you do: https://developer.atlassian.com/server/confluence/pagination-in-the-rest-api/ :param retrieval_method: Function used to retrieve docs :type retrieval_method: callable :return: List of...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-8
"`beautifulsoup4` package not found, please run" " `pip install beautifulsoup4`" ) if include_attachments: attachment_texts = self.process_attachment(page["id"]) else: attachment_texts = [] text = BeautifulSoup( page["body"]["storag...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-9
) # depending on setup you may also need to set the correct path for # poppler and tesseract attachments = self.confluence.get_attachments_from_content(page_id)["results"] texts = [] for attachment in attachments: media_type = attachment["metadata"]["mediaType"] ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-10
except ImportError: raise ImportError( "`pytesseract` or `pdf2image` package not found," "please run `pip install pytesseract pdf2image`" ) import pytesseract # noqa: F811 from pdf2image import convert_from_bytes # noqa: F811 response = s...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-11
except OSError: return text return pytesseract.image_to_string(image) [docs] def process_doc(self, link: str) -> str: try: from io import BytesIO # noqa: F401 import docx2txt # noqa: F401 except ImportError: raise ImportError( ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
1c8ab4f7e063-12
text += "\n" text += "\n" return text [docs] def process_svg(self, link: str) -> str: try: from io import BytesIO # noqa: F401 import pytesseract # noqa: F401 from PIL import Image # noqa: F401 from reportlab.graphics import renderPM # n...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/confluence.html
d2ac4d9c3f01-0
Source code for langchain.document_loaders.word_document """Loader that loads word documents.""" import os from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredWordDocumentLoader(UnstructuredFileLoader): """Loader that uses unstructured to load w...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
d2ac4d9c3f01-1
) if is_doc: from unstructured.partition.doc import partition_doc return partition_doc(filename=self.file_path, **self.unstructured_kwargs) else: from unstructured.partition.docx import partition_docx return partition_docx(filename=self.file_path, **self.u...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/word_document.html
5cf9814c3673-0
Source code for langchain.document_loaders.chatgpt """Load conversations from ChatGPT data export""" import datetime import json from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader def concatenate_rows(message: dict, title: str) -> str: if ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/chatgpt.html
5cf9814c3673-1
messages = d["mapping"] text = "".join( [ concatenate_rows(messages[key]["message"], title) for idx, key in enumerate(messages) if not ( idx == 0 and messages[key]["message"]["author"]...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/chatgpt.html
5658205b4657-0
Source code for langchain.document_loaders.html """Loader that uses unstructured to load HTML files.""" from typing import List from langchain.document_loaders.unstructured import UnstructuredFileLoader [docs]class UnstructuredHTMLLoader(UnstructuredFileLoader): """Loader that uses unstructured to load HTML files."...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html.html
378f1edce068-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/roam.html
f144930656d9-0
Source code for langchain.document_loaders.evernote """Load documents from Evernote. https://gist.github.com/foxmask/7b29c43a161e001ff04afdb2f181e31c """ import hashlib from base64 import b64decode from time import strptime from typing import Any, Dict, List from langchain.docstore.document import Document from langcha...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
f144930656d9-1
elif elem.tag == "resource": resources.append(_parse_resource(elem)) elif elem.tag == "created" or elem.tag == "updated": note_dict[elem.tag] = strptime(elem.text, "%Y%m%dT%H%M%SZ") else: note_dict[elem.tag] = elem.text note_dict["resource"] = resources return...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
f144930656d9-2
"""Load document from EverNote file.""" text = _parse_note_xml(self.file_path) metadata = {"source": self.file_path} return [Document(page_content=text, metadata=metadata)] By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/evernote.html
6921466f9163-0
Source code for langchain.document_loaders.web_base """Web base loader class.""" import asyncio import logging import warnings from typing import Any, List, Optional, Union import aiohttp import requests from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = log...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
6921466f9163-1
return metadata [docs]class WebBaseLoader(BaseLoader): """Loader that uses urllib and beautiful soup to load webpages.""" web_paths: List[str] requests_per_second: int = 2 """Max number of concurrent requests to make.""" default_parser: str = "html.parser" """Default parser to use for BeautifulS...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
6921466f9163-2
logger.info( "fake_useragent not found, using default user agent." "To get a realistic header for requests, `pip install fake_useragent`." ) @property def web_path(self) -> str: if len(self.web_paths) > 1: raise ValueError("Multiple webpaths found....
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
6921466f9163-3
"""Fetch all urls concurrently with rate limiting.""" semaphore = asyncio.Semaphore(self.requests_per_second) tasks = [] for url in urls: task = asyncio.ensure_future(self._fetch_with_rate_limit(url, semaphore)) tasks.append(task) try: from tqdm.asynci...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
6921466f9163-4
from bs4 import BeautifulSoup results = asyncio.run(self.fetch_all(urls)) final_results = [] for i, result in enumerate(results): url = urls[i] if parser is None: if url.endswith(".xml"): parser = "xml" else: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
6921466f9163-5
soup = self._scrape(path) text = soup.get_text() metadata = _build_metadata(soup, path) docs.append(Document(page_content=text, metadata=metadata)) return docs [docs] def aload(self) -> List[Document]: """Load text from the urls in web_path async into Documents."""...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/web_base.html
963f84a30bfe-0
Source code for langchain.document_loaders.s3_file """Loading logic for loading documents from an s3 file.""" import os import tempfile from typing import List from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader from langchain.document_loaders.unstructured import Unst...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/s3_file.html
c37072a17311-0
Source code for langchain.document_loaders.html_bs """Loader that uses bs4 to load HTML files, enriching metadata with page title.""" import logging from typing import Dict, List, Union from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader logger = logging.getLogger(__n...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
c37072a17311-1
soup = BeautifulSoup(f, **self.bs_kwargs) text = soup.get_text() if soup.title: title = str(soup.title.string) else: title = "" metadata: Dict[str, Union[str, None]] = { "source": self.file_path, "title": title, } return [Do...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/html_bs.html
a266070547fb-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/imsdb.html
d37230fc2d0d-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...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html
d37230fc2d0d-1
loader = AzureBlobStorageFileLoader( self.conn_str, self.container, blob.name # type: ignore ) docs.extend(loader.load()) return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/azure_blob_storage_container.html
c2e0612818df-0
Source code for langchain.document_loaders.sitemap """Loader that fetches a sitemap and loads those URLs.""" import re from typing import Any, Callable, List, Optional from langchain.document_loaders.web_base import WebBaseLoader from langchain.schema import Document def _default_parsing_function(content: Any) -> str: ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
c2e0612818df-1
els = [] for url in soup.find_all("url"): loc = url.find("loc") if not loc: continue if self.filter_urls and not any( re.match(r, loc.text) for r in self.filter_urls ): continue els.append( ...
/content/https://python.langchain.com/en/latest/_modules/langchain/document_loaders/sitemap.html
8287855dad66-0
Source code for langchain.llms.llamacpp """Wrapper around llama.cpp.""" import logging from typing import Any, Dict, Generator, List, Optional from pydantic import Field, root_validator from langchain.llms.base import LLM logger = logging.getLogger(__name__) [docs]class LlamaCpp(LLM): """Wrapper around the llama.cp...
/content/https://python.langchain.com/en/latest/_modules/langchain/llms/llamacpp.html
8287855dad66-1
If -1, the number of parts is automatically determined.""" seed: int = Field(-1, alias="seed") """Seed. If -1, a random seed is used.""" f16_kv: bool = Field(True, alias="f16_kv") """Use half-precision for key/value cache.""" logits_all: bool = Field(False, alias="logits_all") """Return logits f...
/content/https://python.langchain.com/en/latest/_modules/langchain/llms/llamacpp.html
8287855dad66-2
"""The temperature to use for sampling.""" top_p: Optional[float] = 0.95 """The top-p value to use for sampling.""" logprobs: Optional[int] = Field(None) """The number of logprobs to return. If None, no logprobs are returned.""" echo: Optional[bool] = False """Whether to echo the prompt.""" ...
/content/https://python.langchain.com/en/latest/_modules/langchain/llms/llamacpp.html