Spaces:
Build error
Build error
Metadata-Version: 2.1 | |
Name: aleph-alpha-client | |
Version: 7.1.0 | |
Summary: python client to interact with Aleph Alpha api endpoints | |
Home-page: https://github.com/Aleph-Alpha/aleph-alpha-client | |
Author: Aleph Alpha | |
Author-email: [email protected] | |
License: MIT | |
Description-Content-Type: text/markdown | |
License-File: LICENSE | |
Requires-Dist: requests >=2.28 | |
Requires-Dist: urllib3 >=1.26 | |
Requires-Dist: aiohttp >=3.8.6 | |
Requires-Dist: aiodns >=3.0.0 | |
Requires-Dist: aiohttp-retry >=2.8.3 | |
Requires-Dist: tokenizers >=0.13.2 | |
Requires-Dist: typing-extensions >=4.5.0 | |
Requires-Dist: Pillow >=9.2.0 | |
Requires-Dist: tqdm >=v4.62.0 | |
Requires-Dist: python-liquid >=1.9.4 | |
Requires-Dist: packaging >=23.2 | |
Provides-Extra: dev | |
Requires-Dist: pytest ; extra == 'dev' | |
Requires-Dist: pytest-cov ; extra == 'dev' | |
Requires-Dist: pytest-dotenv ; extra == 'dev' | |
Requires-Dist: pytest-httpserver ; extra == 'dev' | |
Requires-Dist: pytest-aiohttp ; extra == 'dev' | |
Requires-Dist: mypy ; extra == 'dev' | |
Requires-Dist: types-requests ; extra == 'dev' | |
Requires-Dist: types-Pillow ; extra == 'dev' | |
Requires-Dist: types-tqdm ; extra == 'dev' | |
Requires-Dist: nbconvert ; extra == 'dev' | |
Requires-Dist: ipykernel ; extra == 'dev' | |
Requires-Dist: black ; extra == 'dev' | |
Provides-Extra: docs | |
Requires-Dist: sphinx ; extra == 'docs' | |
Requires-Dist: sphinx-rtd-theme ; extra == 'docs' | |
Provides-Extra: test | |
Requires-Dist: pytest ; extra == 'test' | |
Requires-Dist: pytest-cov ; extra == 'test' | |
Requires-Dist: pytest-dotenv ; extra == 'test' | |
Requires-Dist: pytest-httpserver ; extra == 'test' | |
Requires-Dist: pytest-aiohttp ; extra == 'test' | |
Provides-Extra: types | |
Requires-Dist: mypy ; extra == 'types' | |
Requires-Dist: types-requests ; extra == 'types' | |
Requires-Dist: types-Pillow ; extra == 'types' | |
Requires-Dist: types-tqdm ; extra == 'types' | |
# Aleph Alpha Client | |
<p align="center"> | |
<img src="https://i.imgur.com/FSM2NNV.png" width="50%" /> | |
</p> | |
[](https://github.com/Aleph-Alpha/aleph-alpha-client/blob/main/LICENSE) | |
[](https://pypi.org/project/aleph-alpha-client/) | |
[](https://aleph-alpha-client.readthedocs.io/en/latest/?badge=latest) | |
Python client for the [Aleph Alpha](https://aleph-alpha.com) API. | |
## Usage | |
### Synchronous Client | |
```python | |
import os | |
from aleph_alpha_client import Client, CompletionRequest, Prompt | |
client = Client(token=os.getenv("AA_TOKEN")) | |
request = CompletionRequest( | |
prompt=Prompt.from_text("Provide a short description of AI:"), | |
maximum_tokens=64, | |
) | |
response = client.complete(request, model="luminous-extended") | |
print(response.completions[0].completion) | |
``` | |
### Asynchronous Client | |
```python | |
import os | |
from aleph_alpha_client import AsyncClient, CompletionRequest, Prompt | |
# Can enter context manager within an async function | |
async with AsyncClient(token=os.environ["AA_TOKEN"]) as client: | |
request = CompletionRequest( | |
prompt=Prompt.from_text("Provide a short description of AI:"), | |
maximum_tokens=64, | |
) | |
response = await client.complete(request, model="luminous-base") | |
print(response.completions[0].completion) | |
``` | |
### Interactive Examples | |
This table contains interactive code examples, further exercises can be found in the [examples repository](https://github.com/Aleph-Alpha/examples). | |
| Template | Description | Internal Link | Colab Link | | |
|----------|-------------|---------------| -----------| | |
| 1 | Calling the API | [Template 1](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/01_using_client.ipynb) | [](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/01_using_client.ipynb)| | |
| 2 | Simple completion | [Template 2](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/02_prompting.ipynb) | [](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/02_prompting.ipynb)| | |
| 3 | Simple search | [Template 3](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/03_simple_search.ipynb) | [](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/03_simple_search.ipynb)| | |
| 4 | Symmetric and Asymmetric Search | [Template 4](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/04_semantic_search.ipynb) | [](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/04_semantic_search.ipynb)| | |
| 5 | Hidden Embeddings | [Template 5](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/05_hidden_embeddings.ipynb) | [](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/05_hidden_embeddings.ipynb)| | |
| 6 | Task-specific Endpoints | [Template 6](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/06_task_specific_endpoints.ipynb) | [](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/06_task_specific_endpoints.ipynb)| | |
## Installation | |
The latest stable version is deployed to PyPi so you can install this package via pip. | |
```sh | |
pip install aleph-alpha-client | |
``` | |
Get started using the client by first [creating an account](https://app.aleph-alpha.com/signup). Afterwards head over to [your profile](https://app.aleph-alpha.com/profile) to create an API token. Read more about how you can manage your API tokens [here](https://docs.aleph-alpha.com/docs/account). | |
## Development | |
For local development, start by creating a Python virtual environment as follows: | |
``` | |
python3 -m venv venv | |
. ./venv/bin/activate | |
``` | |
Next, install the `test` and `dev` dependencies: | |
``` | |
pip install -e ".[test,dev]" | |
``` | |
Now you should be able to ... | |
* run all the tests using `pytest` or, `pytest -k <test_name>` to run a specific test | |
* typecheck the code and tests using `mypy aleph_alpha_client` resp. `mypy tests` | |
* format the code using `black .` | |
## Links | |
- [HTTP API Docs](https://docs.aleph-alpha.com/api/) | |
- [Interactive Playground](https://app.aleph-alpha.com/playground/) | |