Crossing Minds RAGsys python library
Project description
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)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ragsys-1.0.1.tar.gz.
File metadata
- Download URL: ragsys-1.0.1.tar.gz
- Upload date:
- Size: 56.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d367290a5b8b30eeb1abdce0e0dfbd67e96dd7efb8554b66d9a7013c1b02dc4f
|
|
| MD5 |
5723c62f76ef35b9fb92240e245c4ac5
|
|
| BLAKE2b-256 |
90d48dfd69b73bebe70be6517b662b92cff42f7fdeebaccbe8ab10429ce93494
|
File details
Details for the file ragsys-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ragsys-1.0.1-py3-none-any.whl
- Upload date:
- Size: 134.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e9937768a609428d9317af8b22025a04055c458c91721ebb2d04afded4418b4
|
|
| MD5 |
cab09dafdc8b5d07eea64ac9bfe3feaa
|
|
| BLAKE2b-256 |
2c0d3ebe3e9edc2fbb0c081459445d4271f0fc05aeacdac8ba5d47eec8e0b3a8
|