Skip to content

Commit 5b49808

Browse files
authored
chore: development enhancements (#57)
1 parent b967343 commit 5b49808

7 files changed

Lines changed: 141 additions & 72 deletions

File tree

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
POETRY=poetry
2+
POETRY_PYTHON=python

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
secrets: inherit
1515
with:
1616
python-version: "3.10"
17-
poetry-version: "1.8.5"
17+
poetry-version: "2.3.2"
1818
code-checks-python-versions: '["3.10", "3.11", "3.12", "3.13"]'

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
secrets: inherit
1515
with:
1616
python-version: "3.10"
17-
poetry-version: "1.8.5"
17+
poetry-version: "2.3.2"
1818
code-checks-python-versions: '["3.10", "3.11", "3.12", "3.13"]'

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
VENV_DIR ?= .venv
2-
POETRY ?= $(VENV_DIR)/bin/poetry
3-
POETRY_VERSION ?= 1.8.5
2+
POETRY ?= poetry
3+
POETRY_PYTHON ?= python
44

55
.PHONY: all init_env install clean lint format test spell_check
66

7+
-include .env
8+
export
9+
710
all: build
811

912
init_env:
10-
python -m venv $(VENV_DIR)
11-
$(VENV_DIR)/bin/pip install poetry==$(POETRY_VERSION) --quiet
13+
$(POETRY) env use $(POETRY_PYTHON)
1214

1315
install: init_env
1416
$(POETRY) install

README.md

Lines changed: 107 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
1-
# AI DIAL Client (Python)
2-
3-
## Table of Contents
4-
5-
- [Authentication](#authentication)
6-
- [API Keys](#api-keys)
7-
- [Bearer Token](#bearer-token)
8-
- [List Deployments](#list-deployments)
9-
- [Make Chat Completions Requests](#make-completions-requests)
10-
- [Without Streaming](#without-streaming)
11-
- [With Streaming](#with-streaming)
12-
- [Working with Files](#working-with-files)
13-
- [Working with URLs](#working-with-urls)
14-
- [Uploading Files](#uploading-files)
15-
- [Downloading Files](#downloading-files)
16-
- [Deleting Files](#deleting-files)
17-
- [Accessing Metadata](#accessing-metadata)
18-
- [Applications](#applications)
19-
- [List Applications](#list-applications)
20-
- [Get Application by Id](#get-application-by-id)
21-
- [Client Pool](#client-pool)
22-
- [Synchronous Client Pool](#synchronous-client-pool)
23-
- [Asynchronous Client Pool](#asynchronous-client-pool)
24-
25-
## Authentication
26-
27-
### API Keys
1+
<h1 align="center">
2+
AI DIAL Client (Python)
3+
</h1>
4+
<p align="center">
5+
<p align="center">
6+
<a href="https://dialx.ai/">
7+
<img src="https://dialx.ai/logo/dialx_logo.svg" alt="About DIALX">
8+
</a>
9+
</p>
10+
<h4 align="center">
11+
<a href="https://discord.gg/ukzj9U9tEe">
12+
<img src="https://img.shields.io/static/v1?label=DIALX%20Community%20on&message=Discord&color=blue&logo=Discord&style=flat-square" alt="Discord">
13+
</a>
14+
</h4>
15+
16+
- [Usage](#usage)
17+
- [Authentication](#authentication)
18+
- [API Keys](#api-keys)
19+
- [Bearer Token](#bearer-token)
20+
- [List Deployments](#list-deployments)
21+
- [Make Chat Completions Requests](#make-completions-requests)
22+
- [Without Streaming](#without-streaming)
23+
- [With Streaming](#with-streaming)
24+
- [Working with Files](#working-with-files)
25+
- [Working with URLs](#working-with-urls)
26+
- [Uploading Files](#uploading-files)
27+
- [Downloading Files](#downloading-files)
28+
- [Deleting Files](#deleting-files)
29+
- [Accessing Metadata](#accessing-metadata)
30+
- [Applications](#applications)
31+
- [List Applications](#list-applications)
32+
- [Get Application by Id](#get-application-by-id)
33+
- [Client Pool](#client-pool)
34+
- [Synchronous Client Pool](#synchronous-client-pool)
35+
- [Asynchronous Client Pool](#asynchronous-client-pool)
36+
- [Development](#development)
37+
- [Pre-requisites](#pre-requisites)
38+
- [Setup](#setup)
39+
- [Main commands](#main-commands)
40+
41+
## Usage
42+
43+
This section outlines how to use the AI DIAL Python client to interact with the DIAL Core API.
44+
It covers authentication methods, making chat completion requests, working with files, managing applications,
45+
and utilizing client pools for efficient connection management.
46+
47+
### Authentication
48+
49+
#### API Keys
2850

2951
For authentication with an API key, pass it during the client initialization:
3052

@@ -66,7 +88,7 @@ async_dial_client = AsyncDial(
6688
)
6789
```
6890

69-
### Bearer Token
91+
#### Bearer Token
7092

7193
You can use a Bearer Token for a token-based authentication of API calls. Client instances will use it to construct the `Authorization` header when making requests:
7294

@@ -115,7 +137,7 @@ dial_client = Dial(
115137
)
116138
```
117139

118-
## List Deployments
140+
### List Deployments
119141

120142
If you want to get a list of available deployments, use `client.deployments.list()` or method:
121143

@@ -128,9 +150,9 @@ If you want to get a list of available deployments, use `client.deployments.list
128150
]
129151
```
130152

131-
## Make Completions Requests
153+
### Make Completions Requests
132154

133-
### Without Streaming
155+
#### Without Streaming
134156

135157
Synchronous:
136158

@@ -203,7 +225,7 @@ ChatCompletionResponse(
203225
)
204226
```
205227

206-
### With Streaming
228+
#### With Streaming
207229

208230
Synchronous:
209231

@@ -304,9 +326,9 @@ ChatCompletionChunk(
304326
)
305327
```
306328

307-
## Working with Files
329+
### Working with Files
308330

309-
### Working with URLs
331+
#### Working with URLs
310332

311333
Files are AI DIAL resources that operate with URL-like objects. Use `pathlib.PurePosixPath` or `str` to create to create new URL-like objects or to get a `string` representation of them.
312334

@@ -341,7 +363,7 @@ sync_client.files.upload(url=absolute_url, ...)
341363

342364
**Note**, that an invalid URL provided to the function, will raise an `InvalidDialURLException` exception.
343365

344-
### Uploading Files
366+
#### Uploading Files
345367

346368
Use `upload()` to add files into your storage bucket:
347369

@@ -367,7 +389,7 @@ sync_client.files.upload(
367389
)
368390
```
369391

370-
### Downloading Files
392+
#### Downloading Files
371393

372394
Use `download()` to download files from your storage bucket:
373395

@@ -406,7 +428,7 @@ result.write_to("./some-local-file.txt")
406428
await result.awrite_to("./some-local-file.txt")
407429
```
408430

409-
### Deleting Files
431+
#### Deleting Files
410432

411433
Use `delete()` to remove files from your storage bucket:
412434

@@ -421,7 +443,7 @@ await async_client.files.delete(
421443
)
422444
```
423445

424-
### Accessing Metadata
446+
#### Accessing Metadata
425447

426448
Use `metadata()` to access metadata of a file:
427449

@@ -450,9 +472,9 @@ FileMetadata(
450472
)
451473
```
452474

453-
## Applications
475+
### Applications
454476

455-
### List Applications
477+
#### List Applications
456478

457479
To get a list of your DIAL applications:
458480

@@ -501,7 +523,7 @@ As a result, you will receive a list of `Application` objects:
501523
]
502524
```
503525

504-
### Get Application by Id
526+
#### Get Application by Id
505527

506528
You can get your DIAL applications by their Ids:
507529

@@ -514,11 +536,11 @@ application = await async_client.application.get("app_id")
514536

515537
As a result, you will receive a list of `Application` objects. Refer to the [previous example](#list-applications).
516538

517-
## Client Pool
539+
### Client Pool
518540

519541
When you need to create multiple DIAL clients and wish to enhance performance by reusing the HTTP connection for the same DIAL instance, consider using synchronous and asynchronous **client pools**.
520542

521-
### Synchronous Client Pool
543+
#### Synchronous Client Pool
522544

523545
```python
524546
from aidial_client import DialClientPool
@@ -534,7 +556,7 @@ second_client = client_pool.create_client(
534556
)
535557
```
536558

537-
### Asynchronous Client Pool
559+
#### Asynchronous Client Pool
538560

539561
```python
540562
from dial_client import (
@@ -551,3 +573,44 @@ second_client = client_pool.create_client(
551573
base_url="https://your-dial-instance.com", bearer_token="your-bearer-token"
552574
)
553575
```
576+
577+
578+
## Development
579+
580+
To set up the development environment and run the project, follow the instructions below.
581+
582+
### Pre-requisites
583+
584+
The following tools are required to work with the project:
585+
586+
1. `Make`
587+
2. `Python 3.10`
588+
3. `Poetry 2.*`. Installation guidance can be found [here](https://python-poetry.org/docs/#installation)
589+
590+
### Setup
591+
592+
1. Create `.env` file in the root of the project. Copy `.env.template` file data to the `.env` and customize the values
593+
if needed. You can customize python and poetry locations.
594+
2. Create and activate virtual environment
595+
```bash
596+
make init_env
597+
source .venv/bin/activate
598+
```
599+
3. Install dependencies
600+
```bash
601+
make install
602+
```
603+
604+
### Main commands
605+
606+
| Command | Description |
607+
|-------------------------|-----------------------------------------------|
608+
| `make install` | Install virtual environment and dependencies |
609+
| `make build` | Build the package |
610+
| `make clean` | Clean virtual environment and build artifacts |
611+
| `make lint` | Run linters |
612+
| `make format` | Run code formatters |
613+
| `make test` | Run tests (e.g., `make test PYTHON=3.12`) |
614+
| `make integration_test` | Run integration tests |
615+
| `make coverage` | Generate test coverage report |
616+
| `make help` | Show available commands |

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
[tool.poetry]
1+
[project]
22
name = "aidial-client"
33
version = "0.5.0rc"
4-
54
description = "A Python client library for the AI DIAL API"
6-
authors = ["EPAM RAIL <SpecialEPM-DIALDevTeam@epam.com>"]
7-
homepage = "https://epam-rail.com"
8-
license = "Apache-2.0"
95
readme = "README.md"
10-
repository = "https://github.com/epam/ai-dial-client-python"
11-
packages = [{ include = "aidial_client" }]
6+
license = "Apache-2.0"
7+
requires-python = ">=3.10,<3.14"
8+
authors = [
9+
{ name = "DIALX", email = "SpecialEPM-DIALDevTeam@epam.com" },
10+
]
11+
dependencies = [
12+
"openai>=1.1.0,<2.0.0",
13+
"httpx>=0.25.0,<1.0",
14+
"pydantic>=1.10,<3",
15+
"aiofiles>=0.5.0",
16+
]
1217

13-
[tool.poetry.dependencies]
14-
python = ">=3.10,<4.0"
15-
openai = ">=1.1.0,<2.0.0"
16-
httpx = ">=0.25.0,<1.0"
17-
pydantic = ">=1.10,<3"
18-
aiofiles = ">=0.5.0"
18+
[project.urls]
19+
Homepage = "https://dialx.ai"
20+
Repository = "https://github.com/epam/ai-dial-client-python"
1921

20-
[tool.setuptools]
21-
packages = ["aidial_client"]
22+
[tool.poetry]
23+
packages = [{ include = "aidial_client" }]
2224

2325
[build-system]
24-
requires = ["poetry-core>=1.0.0"]
26+
requires = ["poetry-core>=2.0"]
2527
build-backend = "poetry.core.masonry.api"
2628

2729
[tool.poetry.group.test.dependencies]

0 commit comments

Comments
 (0)