llama-index readers confluence integration
Project description
Confluence Loader
pip install llama-index-readers-confluence
This loader loads pages from a given Confluence cloud instance. The user needs to specify the base URL for a Confluence
instance to initialize the ConfluenceReader - base URL needs to end with /wiki
.
The user can optionally specify OAuth 2.0 credentials to authenticate with the Confluence instance. If no credentials are
specified, the loader will look for CONFLUENCE_API_TOKEN
or CONFLUENCE_USERNAME
/CONFLUENCE_PASSWORD
environment variables
to proceed with basic authentication.
[!NOTE] Keep in mind
CONFLUENCE_PASSWORD
is not your actual password, but an API Token obtained here: https://id.atlassian.com/manage-profile/security/api-tokens.
The following order is used for checking authentication credentials:
oauth2
api_token
user_name
andpassword
- Environment variable
CONFLUENCE_API_TOKEN
- Environment variable
CONFLUENCE_USERNAME
andCONFLUENCE_PASSWORD
For more on authenticating using OAuth 2.0, checkout:
- https://atlassian-python-api.readthedocs.io/index.html
- https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/
Confluence pages are obtained through one of 4 four mutually exclusive ways:
page_ids
: Load all pages from a list of page idsspace_key
: Load all pages from a spacelabel
: Load all pages with a given labelcql
: Load all pages that match a given CQL query (Confluence Query Language https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/ ).
When page_ids
is specified, include_children
will cause the loader to also load all descendent pages.
When space_key
is specified, page_status
further specifies the status of pages to load: None, 'current', 'archived', 'draft'.
limit (int): Deprecated, use max_num_results
instead.
max_num_results (int): Maximum number of results to return. If None, return all results. Requests are made in batches to achieve the desired number of results.
start(int): Which offset we should jump to when getting pages, only works with space_key
cursor(str): An alternative to start for cql queries, the cursor is a pointer to the next "page" when searching atlassian products. The current one after a search can be found with get_next_cursor()
User 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
ConfluenceReader 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.
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>
Usage
Here's an example usage of the ConfluenceReader.
# Example that reads the pages with the `page_ids`
from llama_index.readers.confluence import ConfluenceReader
token = {"access_token": "<access_token>", "token_type": "<token_type>"}
oauth2_dict = {"client_id": "<client_id>", "token": token}
base_url = "https://yoursite.atlassian.com/wiki"
page_ids = ["<page_id_1>", "<page_id_2>", "<page_id_3"]
space_key = "<space_key>"
reader = ConfluenceReader(
base_url=base_url,
oauth2=oauth2_dict,
client_args={"backoff_and_retry": True},
)
documents = reader.load_data(
space_key=space_key, include_attachments=True, page_status="current"
)
documents.extend(
reader.load_data(
page_ids=page_ids, include_children=True, include_attachments=True
)
)
# Example that fetches the first 5, then the next 5 pages from a space
from llama_index.readers.confluence import ConfluenceReader
token = {"access_token": "<access_token>", "token_type": "<token_type>"}
oauth2_dict = {"client_id": "<client_id>", "token": token}
base_url = "https://yoursite.atlassian.com/wiki"
space_key = "<space_key>"
reader = ConfluenceReader(base_url=base_url, oauth2=oauth2_dict)
documents = reader.load_data(
space_key=space_key,
include_attachments=True,
page_status="current",
start=0,
max_num_results=5,
)
documents.extend(
reader.load_data(
space_key=space_key,
include_children=True,
include_attachments=True,
start=5,
max_num_results=5,
)
)
# Example that fetches the first 5 results from a cql query, the uses the cursor to pick up on the next element
from llama_index.readers.confluence import ConfluenceReader
token = {"access_token": "<access_token>", "token_type": "<token_type>"}
oauth2_dict = {"client_id": "<client_id>", "token": token}
base_url = "https://yoursite.atlassian.com/wiki"
cql = f'type="page" AND label="devops"'
reader = ConfluenceReader(base_url=base_url, oauth2=oauth2_dict)
documents = reader.load_data(cql=cql, max_num_results=5)
cursor = reader.get_next_cursor()
documents.extend(reader.load_data(cql=cql, cursor=cursor, max_num_results=5))
This loader is designed to be used as a way to load data into LlamaIndex.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file llama_index_readers_confluence-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_readers_confluence-0.3.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf6416e00c6344aa342a1f8559ffc2f34b23f0d716146b2e15b3c1e8090ccfeb |
|
MD5 | 8d032086bdde7ec7744cd0800fd899e7 |
|
BLAKE2b-256 | e37a63dac1c11bb209a1c9caced08fc6d656f6734c9f30c1008258da49eef3b2 |
File details
Details for the file llama_index_readers_confluence-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_readers_confluence-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699062a26432bb1eb41a0c36f5142fe1f51762733286bc96dcfa662e28028a7e |
|
MD5 | 49b27a9ce6f2cffadf509252c8c30a2e |
|
BLAKE2b-256 | 7136f34a27d7af0ae061aca00ce7eab3f2f6a7895cf4cd20c58a5ca4ac747ef8 |