embed-client 2.0.0.0__py3-none-any.whl → 3.1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,256 @@
1
+ Metadata-Version: 2.4
2
+ Name: embed-client
3
+ Version: 3.1.0.1
4
+ Summary: Async client for Embedding Service API with comprehensive authentication, SSL/TLS, and mTLS support
5
+ Author-email: Vasiliy Zdanovskiy <vasilyvz@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/vasilyvz/embed-client
8
+ Project-URL: Repository, https://github.com/vasilyvz/embed-client
9
+ Project-URL: Documentation, https://github.com/vasilyvz/embed-client#readme
10
+ Project-URL: Bug Tracker, https://github.com/vasilyvz/embed-client/issues
11
+ Keywords: embedding,async,client,api,authentication,ssl,tls,mtls
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
23
+ Classifier: Topic :: Security
24
+ Classifier: Topic :: System :: Networking
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: aiohttp>=3.8.0
29
+ Requires-Dist: PyJWT>=2.0.0
30
+ Requires-Dist: cryptography>=3.0.0
31
+ Requires-Dist: pydantic>=2.0.0
32
+ Provides-Extra: test
33
+ Requires-Dist: pytest; extra == "test"
34
+ Requires-Dist: pytest-asyncio; extra == "test"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest; extra == "dev"
37
+ Requires-Dist: pytest-asyncio; extra == "dev"
38
+ Requires-Dist: black; extra == "dev"
39
+ Requires-Dist: flake8; extra == "dev"
40
+ Requires-Dist: mypy; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # embed-client
44
+
45
+ Асинхронный клиент для Embedding Service API с поддержкой всех режимов безопасности.
46
+
47
+ ## Возможности
48
+
49
+ - ✅ **Асинхронный API** - полная поддержка async/await
50
+ - ✅ **Все режимы безопасности** - HTTP, HTTPS, mTLS
51
+ - ✅ **Аутентификация** - API Key, JWT, Basic Auth, Certificate
52
+ - ✅ **SSL/TLS поддержка** - полная интеграция с mcp_security_framework
53
+ - ✅ **Конфигурация** - файлы конфигурации, переменные окружения, аргументы
54
+ - ✅ **Обратная совместимость** - API формат не изменился, добавлена только безопасность
55
+ - ✅ **Типизация** - 100% type-annotated код
56
+ - ✅ **Тестирование** - 84+ тестов с полным покрытием
57
+
58
+ ## Quick Start: Примеры запуска
59
+
60
+ ### Базовое использование
61
+
62
+ **Вариант 1: через аргументы командной строки**
63
+
64
+ ```sh
65
+ # HTTP без аутентификации
66
+ python embed_client/example_async_usage.py --base-url http://localhost --port 8001
67
+
68
+ # HTTP с API ключом
69
+ python embed_client/example_async_usage.py --base-url http://localhost --port 8001 \
70
+ --auth-method api_key --api-key admin_key_123
71
+
72
+ # HTTPS с SSL
73
+ python embed_client/example_async_usage.py --base-url https://localhost --port 9443 \
74
+ --ssl-verify-mode CERT_REQUIRED
75
+
76
+ # mTLS с сертификатами
77
+ python embed_client/example_async_usage.py --base-url https://localhost --port 9443 \
78
+ --cert-file certs/client.crt --key-file keys/client.key --ca-cert-file certs/ca.crt
79
+ ```
80
+
81
+ **Вариант 2: через переменные окружения**
82
+
83
+ ```sh
84
+ export EMBED_CLIENT_BASE_URL=http://localhost
85
+ export EMBED_CLIENT_PORT=8001
86
+ export EMBED_CLIENT_AUTH_METHOD=api_key
87
+ export EMBED_CLIENT_API_KEY=admin_key_123
88
+ python embed_client/example_async_usage.py
89
+ ```
90
+
91
+ **Вариант 3: через файл конфигурации**
92
+
93
+ ```sh
94
+ python embed_client/example_async_usage.py --config configs/https_token.json
95
+ ```
96
+
97
+ ### Режимы безопасности
98
+
99
+ #### 1. HTTP (без аутентификации)
100
+ ```python
101
+ from embed_client.async_client import EmbeddingServiceAsyncClient
102
+
103
+ client = EmbeddingServiceAsyncClient(
104
+ base_url="http://localhost",
105
+ port=8001
106
+ )
107
+ ```
108
+
109
+ #### 2. HTTP + Token
110
+ ```python
111
+ from embed_client.config import ClientConfig
112
+
113
+ # API Key
114
+ config = ClientConfig.create_http_token_config(
115
+ "http://localhost", 8001, {"user": "api_key_123"}
116
+ )
117
+
118
+ # JWT
119
+ config = ClientConfig.create_http_jwt_config(
120
+ "http://localhost", 8001, "secret", "username", "password"
121
+ )
122
+
123
+ # Basic Auth
124
+ config = ClientConfig.create_http_basic_config(
125
+ "http://localhost", 8001, "username", "password"
126
+ )
127
+ ```
128
+
129
+ #### 3. HTTPS
130
+ ```python
131
+ config = ClientConfig.create_https_config(
132
+ "https://localhost", 9443,
133
+ ca_cert_file="certs/ca.crt"
134
+ )
135
+ ```
136
+
137
+ #### 4. mTLS (взаимная аутентификация)
138
+ ```python
139
+ config = ClientConfig.create_mtls_config(
140
+ "https://localhost", 9443,
141
+ cert_file="certs/client.crt",
142
+ key_file="keys/client.key",
143
+ ca_cert_file="certs/ca.crt"
144
+ )
145
+ ```
146
+
147
+ ### Программное использование
148
+
149
+ ```python
150
+ import asyncio
151
+ from embed_client.async_client import EmbeddingServiceAsyncClient
152
+ from embed_client.config import ClientConfig
153
+
154
+ async def main():
155
+ # Создание конфигурации
156
+ config = ClientConfig.create_http_token_config(
157
+ "http://localhost", 8001, {"user": "api_key_123"}
158
+ )
159
+
160
+ # Использование клиента
161
+ async with EmbeddingServiceAsyncClient.from_config(config) as client:
162
+ # Проверка статуса
163
+ print(f"Аутентификация: {client.get_auth_method()}")
164
+ print(f"SSL включен: {client.is_ssl_enabled()}")
165
+ print(f"mTLS включен: {client.is_mtls_enabled()}")
166
+
167
+ # Выполнение запроса
168
+ result = await client.cmd("embed", params={"texts": ["hello world"]})
169
+
170
+ # Извлечение данных
171
+ embeddings = client.extract_embeddings(result)
172
+ texts = client.extract_texts(result)
173
+ tokens = client.extract_tokens(result)
174
+ bm25_tokens = client.extract_bm25_tokens(result)
175
+
176
+ print(f"Эмбеддинги: {embeddings}")
177
+ print(f"Тексты: {texts}")
178
+ print(f"Токены: {tokens}")
179
+ print(f"BM25 токены: {bm25_tokens}")
180
+
181
+ if __name__ == "__main__":
182
+ asyncio.run(main())
183
+ ```
184
+
185
+ ## Установка
186
+
187
+ ```bash
188
+ # Установка из PyPI
189
+ pip install embed-client
190
+
191
+ # Установка в режиме разработки
192
+ git clone <repository>
193
+ cd embed-client
194
+ pip install -e .
195
+ ```
196
+
197
+ ## Зависимости
198
+
199
+ - `aiohttp` - асинхронные HTTP запросы
200
+ - `PyJWT>=2.0.0` - JWT токены
201
+ - `cryptography>=3.0.0` - криптография и сертификаты
202
+ - `pydantic>=2.0.0` - валидация конфигурации
203
+
204
+ ## Тестирование
205
+
206
+ ```bash
207
+ # Запуск всех тестов
208
+ pytest tests/
209
+
210
+ # Запуск тестов с покрытием
211
+ pytest tests/ --cov=embed_client
212
+
213
+ # Запуск конкретных тестов
214
+ pytest tests/test_async_client.py -v
215
+ pytest tests/test_config.py -v
216
+ pytest tests/test_auth.py -v
217
+ pytest tests/test_ssl_manager.py -v
218
+ ```
219
+
220
+ ## Документация
221
+
222
+ - [Формат API и режимы безопасности](docs/api_format.md)
223
+ - [Примеры использования](embed_client/example_async_usage.py)
224
+ - [Примеры на русском](embed_client/example_async_usage_ru.py)
225
+
226
+ ## Безопасность
227
+
228
+ ### Рекомендации
229
+
230
+ 1. **Используйте HTTPS** для продакшена
231
+ 2. **Включите проверку сертификатов** (CERT_REQUIRED)
232
+ 3. **Используйте mTLS** для критически важных систем
233
+ 4. **Регулярно обновляйте сертификаты**
234
+ 5. **Храните приватные ключи в безопасном месте**
235
+
236
+ ### Поддерживаемые протоколы
237
+
238
+ - TLS 1.2
239
+ - TLS 1.3
240
+ - SSL 3.0 (устаревший, не рекомендуется)
241
+
242
+ ## Лицензия
243
+
244
+ MIT License
245
+
246
+ ## Автор
247
+
248
+ **Vasiliy Zdanovskiy**
249
+ Email: vasilyvz@gmail.com
250
+
251
+ ---
252
+
253
+ **Важно:**
254
+ - Используйте `--base-url` (через дефис), а не `--base_url` (через подчеркивание).
255
+ - Значение base_url должно содержать `http://` или `https://`.
256
+ - Аргументы должны быть отдельными (через пробел), а не через `=`.
@@ -0,0 +1,17 @@
1
+ embed_client/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
2
+ embed_client/async_client.py,sha256=Zf08g-i_2ylDj4tt9E1TO9swi-zcozFDr4mJdlfiGSI,40222
3
+ embed_client/auth.py,sha256=MMk5XqFIY5htf3Bx0JA_8mJaAiLslpLUIVUaiO84XBw,18310
4
+ embed_client/auth_examples.py,sha256=QX_QWaaeyBAqvSs9uOP1ZVdAe72gJ91e8AP1e7R-yzQ,7361
5
+ embed_client/client_factory.py,sha256=-W2nvzMuyyQNu3_nNmALKHT9uL0Z9nMYTxyQ4bgVOFQ,14279
6
+ embed_client/client_factory_examples.py,sha256=7A2JWkyGEJeOB7p84ijklh8rTyeRUeg2lCIPTfAtahc,11823
7
+ embed_client/config.py,sha256=CzVmduJjuN82uiaxDyMyXJLS2tNOOlDBGwcO76SWjXg,19922
8
+ embed_client/config_examples.py,sha256=9aEF8X4h9nbfSV_CORZLrlWM5KEwuwqW6AcQDPguQ7g,6175
9
+ embed_client/example_async_usage.py,sha256=dndf79MIqZaHvWzbtKrZVwU7G4a5yNL1JPMnMBEdLBg,29803
10
+ embed_client/example_async_usage_ru.py,sha256=3HeP5YoyGd49dRlxNC-2TAh_GbwSW4jJmoLXMpMIfFs,29899
11
+ embed_client/ssl_examples.py,sha256=22lTGhK2bqGJ44uUCpc7v2egY4AP3_ar8RMaTb4KBwU,9346
12
+ embed_client/ssl_manager.py,sha256=Ts6-hKxUUNHdW3yldnoykaDblxWtGbIwKdnzPw__30U,17247
13
+ embed_client-3.1.0.1.dist-info/licenses/LICENSE,sha256=6KdtUcTwmTRbJrAmYjVn7e6S-V42ubeDJ-AiVEzZ510,1075
14
+ embed_client-3.1.0.1.dist-info/METADATA,sha256=mvhUNvCDzryNQh68sFeSyGx9ZG9gyypnkPWrNYqxth4,8633
15
+ embed_client-3.1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ embed_client-3.1.0.1.dist-info/top_level.txt,sha256=uG00A4d9o9DFrhiN7goObpeig72Pniby0E7UpDRgyXY,13
17
+ embed_client-3.1.0.1.dist-info/RECORD,,
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Vasiliy Zdanovskiy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: embed-client
3
- Version: 2.0.0.0
4
- Summary: Async client for Embedding Service API
5
- Author: Your Name
6
- Requires-Dist: aiohttp
7
- Provides-Extra: test
8
- Requires-Dist: pytest; extra == "test"
9
- Requires-Dist: pytest-asyncio; extra == "test"
@@ -1,8 +0,0 @@
1
- embed_client/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
2
- embed_client/async_client.py,sha256=8jsDvHQhtoYNrQ4B2rGHqmniGPVMQeSsrzZZUyMx_J8,26357
3
- embed_client/example_async_usage.py,sha256=6oCDALFebTv1o5k7lB7UuiacP9Scvf2r3gVIVtIrsPk,6623
4
- embed_client/example_async_usage_ru.py,sha256=J9K3UpDJwwwy7gNQzy6G3clX4VoMleBmRk_9vymlIiw,5425
5
- embed_client-2.0.0.0.dist-info/METADATA,sha256=3_4NeyifJYxq9iQQHgmxgegFxeoNPvriW_UpWNsAOmI,254
6
- embed_client-2.0.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- embed_client-2.0.0.0.dist-info/top_level.txt,sha256=uG00A4d9o9DFrhiN7goObpeig72Pniby0E7UpDRgyXY,13
8
- embed_client-2.0.0.0.dist-info/RECORD,,