A generic interface for AI models.
Project description
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.
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
File details
Details for the file cloai-1.1.0.tar.gz
.
File metadata
- Download URL: cloai-1.1.0.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
dbd2056c4f6ad58718a55b98b899433b63df9902de13459dac26cd08371aec7a
|
|
MD5 |
5f096016dd3555c56d32a6d974cf1882
|
|
BLAKE2b-256 |
a20baef5a4dd0ccc502d6a338f1eaa40900bd51d86e87e75d5b0be1b4a769235
|
Provenance
The following attestation bundles were made for cloai-1.1.0.tar.gz
:
Publisher:
pypi.yaml
on childmindresearch/cloai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
cloai-1.1.0.tar.gz
-
Subject digest:
dbd2056c4f6ad58718a55b98b899433b63df9902de13459dac26cd08371aec7a
- Sigstore transparency entry: 218169334
- Sigstore integration time:
-
Permalink:
childmindresearch/cloai@403f0ec032a7d97d0bc7bfc3270e95c673badac5
-
Branch / Tag:
refs/tags/v1.1.0
- Owner: https://github.com/childmindresearch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi.yaml@403f0ec032a7d97d0bc7bfc3270e95c673badac5
-
Trigger Event:
release
-
Statement type:
File details
Details for the file cloai-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: cloai-1.1.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c867d86a25a1b5bbc1e38328a6c89dec635291da0faf438d03673977b43126cb
|
|
MD5 |
057642a4b63cd81960d7b8e045f759c0
|
|
BLAKE2b-256 |
ce10541293aed66069c9711fd403e46f0cbe8db37c167d435ff30aa8294f97dc
|
Provenance
The following attestation bundles were made for cloai-1.1.0-py3-none-any.whl
:
Publisher:
pypi.yaml
on childmindresearch/cloai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
cloai-1.1.0-py3-none-any.whl
-
Subject digest:
c867d86a25a1b5bbc1e38328a6c89dec635291da0faf438d03673977b43126cb
- Sigstore transparency entry: 218169338
- Sigstore integration time:
-
Permalink:
childmindresearch/cloai@403f0ec032a7d97d0bc7bfc3270e95c673badac5
-
Branch / Tag:
refs/tags/v1.1.0
- Owner: https://github.com/childmindresearch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi.yaml@403f0ec032a7d97d0bc7bfc3270e95c673badac5
-
Trigger Event:
release
-
Statement type: