chatproto
Large Language Model Chat Protocol.
The different chat prompt formats used by different Large Language Models have been a problem for developers. We developed chatproto to output the prompt format for different LLMs through a unified interface.
Compared to the apply_chat_format function in HuggingFace and the version in FastChat, ChatProto can locate the position of each message after applying the template. This makes it very convenient for us to mask out certain conversations during training.
Quick Start
from chatproto.conversation.history import ConversationHistory
from chatproto.registry import list_conv_settings, get_conv_settings
# Print all available settings
all_settings = list_conv_settings()
print(all_settings)
settings = get_conv_settings("openbuddy")
history = ConversationHistory(
"SYSTEM_MESSAGE",
messages=[
(settings.roles[0], "Hello!"),
(settings.roles[1], "Hello! How can I assist you today?"),
],
offset=0,
settings=settings
)
# Apply the template
print(history.get_prompt())
# Get prompt and indices
prompt, indices = history.get_prompt_and_indices()
# Print the start and end offsets of each message in the conversation one by one.
# The start and end offsets here refer to the offsets in the text, not the tokens.
# They do not include any additional characters added in the template.
system_start, system_end = indices[0]
for i, (conv_start, conv_end) in enumerate(indices[1:]):
print((conv_start, conv_end))
Install
Method 1: With pip
pip install chatproto
or:
pip install git+https://github.com/vtuber-plan/chatproto.git
Method 2: From source
- Clone this repository
git clone https://github.com/vtuber-plan/chatproto.git
cd chatproto
- Install the Package
pip install --upgrade pip
pip install .
Metadata
Release files for chatproto 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chatproto-0.0.2.tar.gz | 13.0 kB | Without provenance | Details for chatproto-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chatproto-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for chatproto-0.0.2-py3-none-any.whl |
Total release size: 34.7 kB
Release files / chatproto-0.0.2.tar.gz
| Download URL | chatproto-0.0.2.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1578a00947d635499376b0a6e7d3204042d91b46c405255bf31cfff389a90852
|
|
BLAKE2b-256 checksum How to use checksums |
96d8a52e4ceddb3e142bf675d1e18231505209eb03f1343728467e1a581ba729
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.15
|
Release files / chatproto-0.0.2-py3-none-any.whl
| Download URL | chatproto-0.0.2-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15ae27b55a8a8c6a1aa41dbceb12404d661bd8bb270c0df1bbc0762b2142ae27
|
|
BLAKE2b-256 checksum How to use checksums |
96bb32c89e8a8defa70c873bf4c630a2eec57f27c5fd1003952bcc1dc9759089
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.15
|
Security for chatproto 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.