NOTE: This module is unofficial.
This module provides wrapper functions that ease the usage of the ChatPDF Backend APIs.
- Python 3.6+
os
requests
typing
This module is NOT supposed to be published in PyPI for users to avoid mistaking this module for an official one. You can install this module in the usual ways you do from a given Git repository. One method is as follows:
pip install git+https://github.com/Surpris/chatpdf-api-python.git
Please see the examples directory.
# import this module
import chatpdf_api_python as chatpdf
# set API_KEY if necessary.
# The API_KEY can be put in your OS environmental keys 'CHATPDF_API_KEY'
# prior to the import of this module.
chatpdf.API_KEY = '...'
url = '...'
source_id = chatpdf.upload_url(url)
file_path_list = [
'/path/to/your/file1.pdf',
'/path/to/your/file2.pdf',
...
]
source_id = chatpdf.upload_files(file_path_list)
messages = [
{ 'role': 'user', 'content': '...' },
{ 'role': 'user', 'content': '...' },
...
]
reference_sources = True
response = chatpdf.chat(source_id, messages, reference_sources=reference_sources)
reference_sources = False # maybe not necessary
response = chatpdf.start(source_id, reference_sources=reference_sources)
source_ids = [
'source_id_1',
'source_id_2',
...
]
response_code = chatpdf.delete_files(source_ids)
We are welcom to your contributions for improving this module. Any reports, requests, etc. can be posted as issues.
Please use the following template when you post your reports, etc. about this module:
Title: ...
Background (optional): ...
Purpose of your post: ...
Detail of your post: ...
We do not set any coding style other than docstring of functions.
We recommend you to using the NumPy docstring style.
This module uses a user-provided API token for ChatPDF. The users of this module are solely responsible for the handling of their own API token, and we assume no liability for any consequences resulting from such handling. Please be careful NOT to unknowingly disclose the API token. The users are solely responsible for the consequences if the use of this module, or any modified version of this module, results in the disclosure of the user's API token.