Cloai
Cloai is a generic interface to large language models. It enables the usage of various prompting techniques (currently: chain of verification, chain of density, instructor) across a wide variety of models, whilst using an identical interface.
Installation
To install cloai, you can use the following command:
pip install cloai
Usage
First, instantiate a client with a large language model provider. Cloai currently supports OpenAI, Azure OpenAI, AWS Bedrock (Anthropic only), and Ollama:
OpenAI Client
import cloai
client = cloai.OpenAiLlm(api_key="your_key", model="gpt-4o")
Ollama Client
import cloai
client = cloai.OllamaLlm(
model="llama3.2",
base_url="http://localhost:11434/v1",
)
Azure OpenAI Client
import cloai
client = cloai.AzureLlm(
api_key="your_key",
endpoint="your_endpoint",
api_version="version_number",
deployment="your_deployment"
)
AWS Bedrock (Anthropic)
import cloai
client = cloai.AnthropicBedrockLlm(
model="anthropic.claude-3-5-sonnet-20241022-v2:0",
aws_access_key="YOUR_ACCESS_KEY",
aws_secret_key="YOUR_SECRET_KEY",
region="REGION",
)
Once your client is created, you can construct the generic interface and make use of
all the methods, regardless of which LLM you are using. Please be aware that cloai
uses asynchronous clients so you will have to await the promises. If you are in a
synchronous environment, see asyncio.run().
import cloai
import pydantic
model = cloai.LargeLanguageModel(client=client)
# Standard prompt
result = await model.run(system_prompt, user_prompt)
# Instructor
class Response(pydantic.BaseModel):
is_scary: bool
result = await model.call_instructor(
response_model=Response,
system_prompt="Tell the user if a movie is scary.",
user_prompt="Scary movie 3."
)
# Chain of verification
result = model.chain_of_verification(system_prompt, user_prompt)
# Chain of density
result = model.chain_of_density(text)
Contributing
Contributions are welcome! Please see the contributing guidelines for more information.
License
cloai is licensed under the terms of the L-GPLv2.1 license.
Support
If you encounter any issues or have any questions, please report them on our issues page.
Metadata
Release files for cloai 1.1.0
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 |
|---|---|---|---|---|
| cloai-1.1.0.tar.gz | 31.1 kB | With provenance | Details for cloai-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloai-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for cloai-1.1.0-py3-none-any.whl |
Total release size: 53.0 kB
Release files / cloai-1.1.0.tar.gz
| Download URL | cloai-1.1.0.tar.gz |
|---|---|
| Size | 31.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbd2056c4f6ad58718a55b98b899433b63df9902de13459dac26cd08371aec7a
|
|
BLAKE2b-256 checksum How to use checksums |
a20baef5a4dd0ccc502d6a338f1eaa40900bd51d86e87e75d5b0be1b4a769235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 22, 2025.
Transparency logRelease files / cloai-1.1.0-py3-none-any.whl
| Download URL | cloai-1.1.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c867d86a25a1b5bbc1e38328a6c89dec635291da0faf438d03673977b43126cb
|
|
BLAKE2b-256 checksum How to use checksums |
ce10541293aed66069c9711fd403e46f0cbe8db37c167d435ff30aa8294f97dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 22, 2025.
Transparency logSecurity for cloai 1.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cloai-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 22, 2025.
Transparency logA 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.