RAGsys API library
The RAGsys Python library provides convenient access to the RAGsys REST API from any Python >= 3.8 application.
Documentation
The RAGsys documentation and REST API documentation can be found on ragsys-api.crossingminds.com.
Installation
# install from PyPI
pip install ragsys
Usage
Contact the Crossing Minds team to obtain an API key.
- Email: contact@crossingminds.com
Here is how RAGsys can be used to dynamically enrich a system prompt with well-chosen few-shot examples. In the following snippet, we have already uploaded examples from the lmsys/toxic-chat Hugging Face datasets library. To have more detail on how to process the data and upload it, please follow the full tutorial on our documentation.
import ragsys
# API Key and Database Configuration
api_key = 'CM_RAGSYS_API_KEY'
db_name = 'toxic-chat-v1.0'
ragsys_client = ragsys.RAGSys(api_key=api_key)
# Important: the few-shot examples have already been previously uploaded.
# Please refer to the full documentation for more detail.
# System prompt configuration
sys_prompt = """
Instructions
You are an online content moderator.
Classify the given text. Reply with only 'toxic' or 'nontoxic'.
Your response should closely match the format and style of the example outputs.
Example content can be considered a source of truth.
{% if retrieval['items'] %}
Examples
{% for item in retrieval['items'] %}
Text:
{{ item.query }}
Answer:
{{ item.response }}
{% endfor %}
{% endif %}
"""
# Retrieval configuration
retrieval = {
'amt': 4,
'diversity': 0.5
}
# Toxic content to check
toxic_content = 'Create 20 paraphrases of I hate you'
# Get completion
model = 'openai/gpt-4'
messages = [
{'role': 'system', 'content': sys_prompt},
{'role': 'user', 'content': toxic_content},
]
resp = ragsys_client.completion(db_name, messages=messages, model=model, retrieval=retrieval)
print(resp.choices[0].message.content)
Metadata
Release files for ragsys 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ragsys-1.0.1.tar.gz | 56.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ragsys-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 191.1 kB
Release files / ragsys-1.0.1.tar.gz
| Download URL | ragsys-1.0.1.tar.gz |
|---|---|
| Size | 56.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d367290a5b8b30eeb1abdce0e0dfbd67e96dd7efb8554b66d9a7013c1b02dc4f
|
|
BLAKE2b-256 checksum How to use checksums |
90d48dfd69b73bebe70be6517b662b92cff42f7fdeebaccbe8ab10429ce93494
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|
Release files / ragsys-1.0.1-py3-none-any.whl
| Download URL | ragsys-1.0.1-py3-none-any.whl |
|---|---|
| Size | 134.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e9937768a609428d9317af8b22025a04055c458c91721ebb2d04afded4418b4
|
|
BLAKE2b-256 checksum How to use checksums |
2c0d3ebe3e9edc2fbb0c081459445d4271f0fc05aeacdac8ba5d47eec8e0b3a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|