pangea-llm-translators
Description
llm-message-translator is a Python library designed to transform messages for various LLM (Large Language Model) providers to Pangea messages format. It supports multiple AI models and platforms, including:
- OpenAI
- Mistral
- LangChain
- Gemini (Google AI)
- DBRX (Databricks)
- Cohere
- Claude (Anthropic)
- AWS Bedrock
- Pangea
Features
- Seamlessly convert various LLM message formats to the Pangea Messages format.
- Preserve message structure while transforming the original input using responses from Pangea AI Guard APIs.
Installation
pip install pangea-llm-translator
Usage Example
from pangea_translator import get_translator
# Define an OpenAI-style LLM input
openapi_message = {
"model": "gpt-4o",
"messages": [
{"role": "developer", "content": "you are a joker"},
{"role": "user", "content": [{"type": "text", "text": "knock knock"}]},
{"role": "assistant", "content": [{"type": "text", "text": "Who's there?"}]},
],
}
# Initialize the translator
translator = get_translator(openapi_message, llm_hint="openai")
# Convert to Pangea format
pangea_messages = translator.get_pangea_messages()
# Print transformed messages
print(pangea_messages.get_messages_list())
# [{'role': 'system', 'content': 'you are a joker'}, {'role': 'user', 'content': 'knock knock'}, {'role': 'assistant', 'content': "Who's there?"}]
# Mimic some api behavior like modify content (Example: Censor "joker")
for message in pangea_messages.messages:
message.content = message.content.replace("joker", "*****")
# Convert back to OpenAPI input format
original_output = translator.transformed_original_input(messages=pangea_messages.get_messages_list())
print(original_output)
Development
Prerequisites
Ensure you have the following installed:
- Python 3.9+
- Poetry
Installation
- Clone the repository:
git clone https://github.com/pangeacyber/pangea-llm-translators.git cd pangea-llm-translators
- Install dependencies using Poetry:
poetry install
Virtual Environment
To activate the virtual environment:
poetry shell
Running Tests
To run the test suite, use:
poetry run pytest
Running the Application
To run the application, use:
poetry run python examples/openai_translator.py
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please create an issue or submit a pull request.
Metadata
Release files for pangea-llm-translator 1.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 | |
|---|---|---|---|---|
| pangea_llm_translator-1.0.2.tar.gz | 13.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pangea_llm_translator-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.2 kB
Release files / pangea_llm_translator-1.0.2.tar.gz
| Download URL | pangea_llm_translator-1.0.2.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14fb5e427ee137309bfd6612e6a4af7f69ad91f246e156b15a93e62c46d23eea
|
|
BLAKE2b-256 checksum How to use checksums |
fc80bc7d1402bb1e03cea7fd8ef8e155d6631b40f2dd6932dd4c51db18e27482
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure
|
Release files / pangea_llm_translator-1.0.2-py3-none-any.whl
| Download URL | pangea_llm_translator-1.0.2-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7fd8603fa8918a877abc069da73c84b81513d7d2ac3433295d694367caca5675
|
|
BLAKE2b-256 checksum How to use checksums |
bce462697aa6baf25506de384850ccfa1507eb893d823221e80eec8ac1aa4545
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure
|
Security for pangea-llm-translator 1.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.