Docs /Templates/ sinapsis_langchain_readers

ConfluenceLoaderExecuteNTimes

sinapsis_langchain_readersLangChaindocumentsdocument_loadingdynamicfiles

Python template · sinapsis_langchain_readers.templates.langchain_data_readers

Overview

Dynamic Template to load documents from Langchain document_loaders module The template loads the document either as a Document object in the generic_data field of DataContainer of each string as a TextPacket if add_document_as_text_packet is set as True

ConfluenceLoader — inherited documentation

Load `Confluence` pages.

Port of https://llamahub.ai/l/confluence This currently supports username/api_key, Oauth2 login, personal access token or cookies authentication.

Specify a list page_ids and/or space_key to load in the corresponding pages into Document objects, if both are specified the union of both sets will be returned.

You can also specify a boolean `include_attachments` to include attachments, this is set to False by default, if set to True all attachments will be downloaded and ConfluenceLoader will extract the text from the attachments and add it to the Document object. Currently supported attachment types are: PDF, PNG, JPEG/JPG, SVG, Word and Excel.

Confluence API supports difference format of page content. The storage format is the raw XML representation for storage. The view format is the HTML representation for viewing with macros are rendered as though it is viewed by users. You can pass a enum `content_format` argument to specify the content format, this is set to `ContentFormat.STORAGE` by default, the supported values are: `ContentFormat.EDITOR`, `ContentFormat.EXPORT_VIEW`, `ContentFormat.ANONYMOUS_EXPORT_VIEW`, `ContentFormat.STORAGE`, and `ContentFormat.VIEW`.

Hint: space_key and page_id can both be found in the URL of a page in Confluence - https://yoursite.atlassian.com/wiki/spaces/<space_key>/pages/<page_id>

Example: .. code-block:: python

from langchain_community.document_loaders import ConfluenceLoader

loader = ConfluenceLoader( url="https://yoursite.atlassian.com/wiki", username="me", api_key="12345", space_key="SPACE", limit=50, ) documents = loader.load()

# Server on perm loader = ConfluenceLoader( url="https://confluence.yoursite.com/", username="me", api_key="your_password", cloud=False, space_key="SPACE", limit=50, ) documents = loader.load()

:param url: _description_ :type url: str :param api_key: _description_, defaults to None :type api_key: str, optional :param username: _description_, defaults to None :type username: str, optional :param oauth2: _description_, defaults to {} :type oauth2: dict, optional :param token: _description_, defaults to None :type token: str, optional :param cloud: _description_, defaults to True :type cloud: bool, optional :param number_of_retries: How many times to retry, defaults to 3 :type number_of_retries: Optional[int], optional :param min_retry_seconds: defaults to 2 :type min_retry_seconds: Optional[int], optional :param max_retry_seconds: defaults to 10 :type max_retry_seconds: Optional[int], optional :param confluence_kwargs: additional kwargs to initialize confluence with :type confluence_kwargs: dict, optional :param cookies: _description_, defaults to {} :type cookies: dict, optional :param space_key: Space key retrieved from a confluence URL, defaults to None :type space_key: Optional[str], optional :param page_ids: List of specific page IDs to load, defaults to None :type page_ids: Optional[List[str]], optional :param label: Get all pages with this label, defaults to None :type label: Optional[str], optional :param cql: CQL Expression, defaults to None :type cql: Optional[str], optional :param include_restricted_content: defaults to False :type include_restricted_content: bool, optional :param include_archived_content: Whether to include archived content, defaults to False :type include_archived_content: bool, optional :param include_attachments: defaults to False :type include_attachments: bool, optional :param attachment_filter_func: A function that takes the attachment information from Confluence and decides whether or not the attachment is processed. :param include_comments: defaults to False :type include_comments: bool, optional :param content_format: Specify content format, defaults to ContentFormat.STORAGE, the supported values are: `ContentFormat.EDITOR`, `ContentFormat.EXPORT_VIEW`, `ContentFormat.ANONYMOUS_EXPORT_VIEW`, `ContentFormat.STORAGE`, and `ContentFormat.VIEW`. :type content_format: ContentFormat :param limit: Maximum number of pages to retrieve per request, defaults to 50 :type limit: int, optional :param max_pages: Maximum number of pages to retrieve in total, defaults 1000 :type max_pages: int, optional :param ocr_languages: The languages to use for the Tesseract agent. To use a language, you'll first need to install the appropriate Tesseract language pack. :type ocr_languages: str, optional :param keep_markdown_format: Whether to keep the markdown format, defaults to False :type keep_markdown_format: bool :param keep_newlines: Whether to keep the newlines format, defaults to False :type keep_newlines: bool :raises ValueError: Errors while validating input :raises ImportError: Required dependencies not installed.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis_langchain_readers==1.0.0
uv pip install sinapsis_langchain_readers==1.0.0
uv add sinapsis_langchain_readers==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
n_times_execute
int
Optional
Default: 1
confluenceloader_initRequired
__init__Attributes
Required
Default: null
cql
typing.Optional[str]
Optional
Default: null
url
str
Optional
Default: null
cloud
typing.Optional[bool]
Optional
Default: true
label
typing.Optional[str]
Optional
Default: null
limit
typing.Optional[int]
Optional
Default: 50
token
typing.Optional[str]
Optional
Default: null
oauth2
typing.Optional[dict]
Optional
Default: null
api_key
typing.Optional[str]
Optional
Default: null
cookies
typing.Optional[dict]
Optional
Default: null
session
typing.Optional[requests.sessions.Session]
Optional
Default: null
page_ids
typing.Optional[typing.List[str]]
Optional
Default: null
username
typing.Optional[str]
Optional
Default: null
max_pages
typing.Optional[int]
Optional
Default: 1000
space_key
typing.Optional[str]
Optional
Default: null
keep_newlines
bool
Optional
Default: false
ocr_languages
typing.Optional[str]
Optional
Default: null
content_format
ContentFormat
Optional
Default: "body.storage"
include_labels
bool
Optional
Default: false
include_comments
bool
Optional
Default: false
confluence_kwargs
typing.Optional[dict]
Optional
Default: null
max_retry_seconds
typing.Optional[int]
Optional
Default: 10
min_retry_seconds
typing.Optional[int]
Optional
Default: 2
number_of_retries
typing.Optional[int]
Optional
Default: 3
include_attachments
bool
Optional
Default: false
keep_markdown_format
bool
Optional
Default: false
attachment_filter_func
typing.Optional[typing.Callable[[dict], bool]]
Optional
Default: null
include_archived_content
bool
Optional
Default: false
include_restricted_content
bool
Optional
Default: false
add_document_as_text_packet
bool
Optional
Default: false

Configuration example

Generated from documented defaults. Replace any placeholders and complete required nested settings before running.

yaml
templates:
  - template_name: "ConfluenceLoaderExecuteNTimes"
    class_name: "ConfluenceLoaderExecuteNTimes"
    attributes:
      n_times_execute: 1
      confluenceloader_init:
        cql: null
        url: null
        cloud: true
        label: null
        limit: 50
        token: null
        oauth2: null
        api_key: null
        cookies: null
        session: null
        page_ids: null
        username: null
        max_pages: 1000
        space_key: null
        keep_newlines: false
        ocr_languages: null
        content_format: {}
        include_labels: false
        include_comments: false
        confluence_kwargs: null
        max_retry_seconds: 10
        min_retry_seconds: 2
        number_of_retries: 3
        include_attachments: false
        keep_markdown_format: false
        attachment_filter_func: null
        include_archived_content: false
        include_restricted_content: false
      add_document_as_text_packet: false
View original docstring example

The source example references WikipediaLoaderWrapper, not ConfluenceLoaderExecuteNTimes.

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: WikipediaLoaderWrapper
  class_name: WikipediaLoaderWrapper    ## note that because it is a dynamic template,
  template_input: InputTemplate         ##  the class name depends on the actual class that is used.
  attributes:
    add_document_as_text_packet: false
    wikipedialoader_init:
        query: the query for wikipedia
        lang: en
        load_max_docs: 5000
        load_all_available_meta: False
        doc_content_chars_max: 4000, 
n_times_execute determines the number of times the template's execute
method is called. By default, it only gets called once. Further calls
to execute are bypassed.

Inheritance

Immediate parent: sinapsis_langchain_readers.templates.langchain_data_readers.ExecuteNTimesLangchainDataReaders

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere