The official Python library for the AI71 API
Project description
Developers building Python 3.8+ apps can now interact seamlessly with the AI71 API thanks to the ai71 Python library. It includes built-in type checking for both requests and responses, and provides both synchronous and asynchronous HTTP clients powered by httpx.
Documentation
The API documentation can be found here.
Installation
pip install ai71
Usage
Define AI71_API_KEY
environment variable or provide api_key
in AI71
and AsyncAI71
.
import os
from ai71 import AI71
client = AI71()
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": "What is your name?"}],
model="tiiuae/falcon-180B-chat",
)
Async Usage
import asyncio
from ai71 import AsyncAI71
client = AsyncAI71()
async def main():
stream = await client.chat.completions.create(
messages=[{"role": "user", "content": "What is your name?"}],
model="tiiuae/falcon-180B-chat",
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ai71-0.0.21.tar.gz
(6.3 kB
view details)
Built Distribution
ai71-0.0.21-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file ai71-0.0.21.tar.gz
.
File metadata
- Download URL: ai71-0.0.21.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.8.0-40-lowlatency
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 272ac2aa6eca7f27c5eedb8445401d5869904284207b5bfbebf8f2ee57ae88db |
|
MD5 | 1fbf819158ac275f13df513eecae8d70 |
|
BLAKE2b-256 | cc9e19c056ee05808ccbb0596a7d37ae9489dabc2c979b0f6902ce5bf6537229 |
File details
Details for the file ai71-0.0.21-py3-none-any.whl
.
File metadata
- Download URL: ai71-0.0.21-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.8.0-40-lowlatency
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d6d96c4c7e41df7120e04798814abd23e45bae0195d0b55d8e8435bdba356df |
|
MD5 | ef7ac6d6a56130c5eb66bba566eda898 |
|
BLAKE2b-256 | cda3f7e73b5617085f39dbfd99df104d130739a0fca547b9280a0e2084f33cda |