embed-client 2.0.0.0__tar.gz → 3.1.0.1__tar.gz

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.
Files changed (80) hide show
  1. embed_client-3.1.0.1/LICENSE +21 -0
  2. embed_client-3.1.0.1/MANIFEST.in +15 -0
  3. embed_client-3.1.0.1/PKG-INFO +256 -0
  4. embed_client-3.1.0.1/README.md +214 -0
  5. embed_client-3.1.0.1/configs/basic_auth.json +52 -0
  6. embed_client-3.1.0.1/configs/http.json +38 -0
  7. embed_client-3.1.0.1/configs/http_correct.json +12 -0
  8. embed_client-3.1.0.1/configs/http_simple.json +52 -0
  9. embed_client-3.1.0.1/configs/http_test.json +12 -0
  10. embed_client-3.1.0.1/configs/http_token.json +52 -0
  11. embed_client-3.1.0.1/configs/http_token_correct.json +15 -0
  12. embed_client-3.1.0.1/configs/http_token_roles.json +56 -0
  13. embed_client-3.1.0.1/configs/https.json +38 -0
  14. embed_client-3.1.0.1/configs/https_api_test.json +16 -0
  15. embed_client-3.1.0.1/configs/https_simple.json +52 -0
  16. embed_client-3.1.0.1/configs/https_test.json +15 -0
  17. embed_client-3.1.0.1/configs/https_token.json +52 -0
  18. embed_client-3.1.0.1/configs/https_token_roles.json +56 -0
  19. embed_client-3.1.0.1/configs/jwt.json +52 -0
  20. embed_client-3.1.0.1/configs/mtls.json +38 -0
  21. embed_client-3.1.0.1/configs/mtls_correct.json +23 -0
  22. embed_client-3.1.0.1/configs/mtls_roles.json +44 -0
  23. embed_client-3.1.0.1/configs/mtls_test.json +22 -0
  24. embed_client-3.1.0.1/configs/mtls_token_roles.json +56 -0
  25. embed_client-3.1.0.1/configs/roles.json +23 -0
  26. embed_client-3.1.0.1/configs/test_server_http.json +16 -0
  27. embed_client-3.1.0.1/configs/test_server_https.json +16 -0
  28. embed_client-3.1.0.1/configs/test_server_mtls.json +51 -0
  29. embed_client-3.1.0.1/docs/api_format.md +401 -0
  30. embed_client-3.1.0.1/docs/coverage_report.md +119 -0
  31. embed_client-3.1.0.1/docs/error_500_analysis.md +213 -0
  32. embed_client-3.1.0.1/docs/error_handling_complete.md +134 -0
  33. embed_client-3.1.0.1/docs/error_handling_issue.md +96 -0
  34. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/embed_client/async_client.py +376 -16
  35. embed_client-3.1.0.1/embed_client/auth.py +491 -0
  36. embed_client-3.1.0.1/embed_client/auth_examples.py +248 -0
  37. embed_client-3.1.0.1/embed_client/client_factory.py +396 -0
  38. embed_client-3.1.0.1/embed_client/client_factory_examples.py +353 -0
  39. embed_client-3.1.0.1/embed_client/config.py +592 -0
  40. embed_client-3.1.0.1/embed_client/config_examples.py +197 -0
  41. embed_client-3.1.0.1/embed_client/example_async_usage.py +653 -0
  42. embed_client-3.1.0.1/embed_client/example_async_usage_ru.py +562 -0
  43. embed_client-3.1.0.1/embed_client/ssl_examples.py +329 -0
  44. embed_client-3.1.0.1/embed_client/ssl_manager.py +475 -0
  45. embed_client-3.1.0.1/embed_client.egg-info/PKG-INFO +256 -0
  46. embed_client-3.1.0.1/embed_client.egg-info/SOURCES.txt +69 -0
  47. embed_client-3.1.0.1/embed_client.egg-info/requires.txt +15 -0
  48. embed_client-3.1.0.1/examples/README.md +286 -0
  49. embed_client-3.1.0.1/examples/configs/http_simple.json +12 -0
  50. embed_client-3.1.0.1/examples/configs/https_token.json +17 -0
  51. embed_client-3.1.0.1/examples/configs/mtls_roles.json +29 -0
  52. embed_client-3.1.0.1/examples/security_examples.py +472 -0
  53. embed_client-3.1.0.1/examples/security_examples_ru.py +472 -0
  54. embed_client-3.1.0.1/pyproject.toml +61 -0
  55. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/tests/test_async_client.py +8 -8
  56. embed_client-3.1.0.1/tests/test_async_client_real.py +305 -0
  57. embed_client-3.1.0.1/tests/test_auth.py +459 -0
  58. embed_client-3.1.0.1/tests/test_client_factory.py +491 -0
  59. embed_client-3.1.0.1/tests/test_config.py +374 -0
  60. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/tests/test_example_async_usage.py +9 -1
  61. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/tests/test_example_async_usage_ru.py +9 -1
  62. embed_client-3.1.0.1/tests/test_server.py +332 -0
  63. embed_client-3.1.0.1/tests/test_ssl_manager.py +399 -0
  64. embed_client-3.1.0.1/tests/test_with_auth.py +235 -0
  65. embed_client-2.0.0.0/PKG-INFO +0 -9
  66. embed_client-2.0.0.0/README.md +0 -24
  67. embed_client-2.0.0.0/embed_client/example_async_usage.py +0 -165
  68. embed_client-2.0.0.0/embed_client/example_async_usage_ru.py +0 -128
  69. embed_client-2.0.0.0/embed_client.egg-info/PKG-INFO +0 -9
  70. embed_client-2.0.0.0/embed_client.egg-info/SOURCES.txt +0 -18
  71. embed_client-2.0.0.0/embed_client.egg-info/requires.txt +0 -5
  72. embed_client-2.0.0.0/pyproject.toml +0 -21
  73. embed_client-2.0.0.0/tests/test_async_client_real.py +0 -149
  74. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/embed_client/__init__.py +0 -0
  75. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/embed_client.egg-info/dependency_links.txt +0 -0
  76. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/embed_client.egg-info/top_level.txt +0 -0
  77. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/setup.cfg +0 -0
  78. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/tests/test_async_client_stress.py +0 -0
  79. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/tests/test_async_client_stress_new.py +0 -0
  80. {embed_client-2.0.0.0 → embed_client-3.1.0.1}/tests/test_async_client_stress_updated.py +0 -0
@@ -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.
@@ -0,0 +1,15 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include examples *.py *.md *.json
5
+ recursive-include docs *.md
6
+ recursive-include configs *.json
7
+ recursive-exclude * __pycache__
8
+ recursive-exclude * *.py[co]
9
+ recursive-exclude * .pytest_cache
10
+ recursive-exclude * .git*
11
+ recursive-exclude * .venv
12
+ recursive-exclude * tests
13
+ recursive-exclude * mtls_certificates
14
+ recursive-exclude * logs
15
+ recursive-exclude * test_environment
@@ -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,214 @@
1
+ # embed-client
2
+
3
+ Асинхронный клиент для Embedding Service API с поддержкой всех режимов безопасности.
4
+
5
+ ## Возможности
6
+
7
+ - ✅ **Асинхронный API** - полная поддержка async/await
8
+ - ✅ **Все режимы безопасности** - HTTP, HTTPS, mTLS
9
+ - ✅ **Аутентификация** - API Key, JWT, Basic Auth, Certificate
10
+ - ✅ **SSL/TLS поддержка** - полная интеграция с mcp_security_framework
11
+ - ✅ **Конфигурация** - файлы конфигурации, переменные окружения, аргументы
12
+ - ✅ **Обратная совместимость** - API формат не изменился, добавлена только безопасность
13
+ - ✅ **Типизация** - 100% type-annotated код
14
+ - ✅ **Тестирование** - 84+ тестов с полным покрытием
15
+
16
+ ## Quick Start: Примеры запуска
17
+
18
+ ### Базовое использование
19
+
20
+ **Вариант 1: через аргументы командной строки**
21
+
22
+ ```sh
23
+ # HTTP без аутентификации
24
+ python embed_client/example_async_usage.py --base-url http://localhost --port 8001
25
+
26
+ # HTTP с API ключом
27
+ python embed_client/example_async_usage.py --base-url http://localhost --port 8001 \
28
+ --auth-method api_key --api-key admin_key_123
29
+
30
+ # HTTPS с SSL
31
+ python embed_client/example_async_usage.py --base-url https://localhost --port 9443 \
32
+ --ssl-verify-mode CERT_REQUIRED
33
+
34
+ # mTLS с сертификатами
35
+ python embed_client/example_async_usage.py --base-url https://localhost --port 9443 \
36
+ --cert-file certs/client.crt --key-file keys/client.key --ca-cert-file certs/ca.crt
37
+ ```
38
+
39
+ **Вариант 2: через переменные окружения**
40
+
41
+ ```sh
42
+ export EMBED_CLIENT_BASE_URL=http://localhost
43
+ export EMBED_CLIENT_PORT=8001
44
+ export EMBED_CLIENT_AUTH_METHOD=api_key
45
+ export EMBED_CLIENT_API_KEY=admin_key_123
46
+ python embed_client/example_async_usage.py
47
+ ```
48
+
49
+ **Вариант 3: через файл конфигурации**
50
+
51
+ ```sh
52
+ python embed_client/example_async_usage.py --config configs/https_token.json
53
+ ```
54
+
55
+ ### Режимы безопасности
56
+
57
+ #### 1. HTTP (без аутентификации)
58
+ ```python
59
+ from embed_client.async_client import EmbeddingServiceAsyncClient
60
+
61
+ client = EmbeddingServiceAsyncClient(
62
+ base_url="http://localhost",
63
+ port=8001
64
+ )
65
+ ```
66
+
67
+ #### 2. HTTP + Token
68
+ ```python
69
+ from embed_client.config import ClientConfig
70
+
71
+ # API Key
72
+ config = ClientConfig.create_http_token_config(
73
+ "http://localhost", 8001, {"user": "api_key_123"}
74
+ )
75
+
76
+ # JWT
77
+ config = ClientConfig.create_http_jwt_config(
78
+ "http://localhost", 8001, "secret", "username", "password"
79
+ )
80
+
81
+ # Basic Auth
82
+ config = ClientConfig.create_http_basic_config(
83
+ "http://localhost", 8001, "username", "password"
84
+ )
85
+ ```
86
+
87
+ #### 3. HTTPS
88
+ ```python
89
+ config = ClientConfig.create_https_config(
90
+ "https://localhost", 9443,
91
+ ca_cert_file="certs/ca.crt"
92
+ )
93
+ ```
94
+
95
+ #### 4. mTLS (взаимная аутентификация)
96
+ ```python
97
+ config = ClientConfig.create_mtls_config(
98
+ "https://localhost", 9443,
99
+ cert_file="certs/client.crt",
100
+ key_file="keys/client.key",
101
+ ca_cert_file="certs/ca.crt"
102
+ )
103
+ ```
104
+
105
+ ### Программное использование
106
+
107
+ ```python
108
+ import asyncio
109
+ from embed_client.async_client import EmbeddingServiceAsyncClient
110
+ from embed_client.config import ClientConfig
111
+
112
+ async def main():
113
+ # Создание конфигурации
114
+ config = ClientConfig.create_http_token_config(
115
+ "http://localhost", 8001, {"user": "api_key_123"}
116
+ )
117
+
118
+ # Использование клиента
119
+ async with EmbeddingServiceAsyncClient.from_config(config) as client:
120
+ # Проверка статуса
121
+ print(f"Аутентификация: {client.get_auth_method()}")
122
+ print(f"SSL включен: {client.is_ssl_enabled()}")
123
+ print(f"mTLS включен: {client.is_mtls_enabled()}")
124
+
125
+ # Выполнение запроса
126
+ result = await client.cmd("embed", params={"texts": ["hello world"]})
127
+
128
+ # Извлечение данных
129
+ embeddings = client.extract_embeddings(result)
130
+ texts = client.extract_texts(result)
131
+ tokens = client.extract_tokens(result)
132
+ bm25_tokens = client.extract_bm25_tokens(result)
133
+
134
+ print(f"Эмбеддинги: {embeddings}")
135
+ print(f"Тексты: {texts}")
136
+ print(f"Токены: {tokens}")
137
+ print(f"BM25 токены: {bm25_tokens}")
138
+
139
+ if __name__ == "__main__":
140
+ asyncio.run(main())
141
+ ```
142
+
143
+ ## Установка
144
+
145
+ ```bash
146
+ # Установка из PyPI
147
+ pip install embed-client
148
+
149
+ # Установка в режиме разработки
150
+ git clone <repository>
151
+ cd embed-client
152
+ pip install -e .
153
+ ```
154
+
155
+ ## Зависимости
156
+
157
+ - `aiohttp` - асинхронные HTTP запросы
158
+ - `PyJWT>=2.0.0` - JWT токены
159
+ - `cryptography>=3.0.0` - криптография и сертификаты
160
+ - `pydantic>=2.0.0` - валидация конфигурации
161
+
162
+ ## Тестирование
163
+
164
+ ```bash
165
+ # Запуск всех тестов
166
+ pytest tests/
167
+
168
+ # Запуск тестов с покрытием
169
+ pytest tests/ --cov=embed_client
170
+
171
+ # Запуск конкретных тестов
172
+ pytest tests/test_async_client.py -v
173
+ pytest tests/test_config.py -v
174
+ pytest tests/test_auth.py -v
175
+ pytest tests/test_ssl_manager.py -v
176
+ ```
177
+
178
+ ## Документация
179
+
180
+ - [Формат API и режимы безопасности](docs/api_format.md)
181
+ - [Примеры использования](embed_client/example_async_usage.py)
182
+ - [Примеры на русском](embed_client/example_async_usage_ru.py)
183
+
184
+ ## Безопасность
185
+
186
+ ### Рекомендации
187
+
188
+ 1. **Используйте HTTPS** для продакшена
189
+ 2. **Включите проверку сертификатов** (CERT_REQUIRED)
190
+ 3. **Используйте mTLS** для критически важных систем
191
+ 4. **Регулярно обновляйте сертификаты**
192
+ 5. **Храните приватные ключи в безопасном месте**
193
+
194
+ ### Поддерживаемые протоколы
195
+
196
+ - TLS 1.2
197
+ - TLS 1.3
198
+ - SSL 3.0 (устаревший, не рекомендуется)
199
+
200
+ ## Лицензия
201
+
202
+ MIT License
203
+
204
+ ## Автор
205
+
206
+ **Vasiliy Zdanovskiy**
207
+ Email: vasilyvz@gmail.com
208
+
209
+ ---
210
+
211
+ **Важно:**
212
+ - Используйте `--base-url` (через дефис), а не `--base_url` (через подчеркивание).
213
+ - Значение base_url должно содержать `http://` или `https://`.
214
+ - Аргументы должны быть отдельными (через пробел), а не через `=`.
@@ -0,0 +1,52 @@
1
+ {
2
+ "server": {
3
+ "host": "localhost",
4
+ "port": 8001,
5
+ "base_url": "http://localhost:8001"
6
+ },
7
+ "timeout": 30,
8
+ "retry_attempts": 3,
9
+ "retry_delay": 1,
10
+ "auth": {
11
+ "method": "basic",
12
+ "api_key": {
13
+ "key": null,
14
+ "header": "X-API-Key"
15
+ },
16
+ "jwt": {
17
+ "username": null,
18
+ "password": null,
19
+ "secret": null,
20
+ "expiry_hours": 24
21
+ },
22
+ "certificate": {
23
+ "enabled": false,
24
+ "cert_file": null,
25
+ "key_file": null,
26
+ "ca_cert_file": null
27
+ },
28
+ "basic": {
29
+ "username": "user",
30
+ "password": "password"
31
+ }
32
+ },
33
+ "ssl": {
34
+ "enabled": false,
35
+ "verify": true,
36
+ "check_hostname": true,
37
+ "cert_file": null,
38
+ "key_file": null,
39
+ "ca_cert_file": null,
40
+ "client_cert_required": false
41
+ },
42
+ "security": {
43
+ "enabled": false,
44
+ "roles_enabled": false,
45
+ "roles_file": null
46
+ },
47
+ "logging": {
48
+ "enabled": false,
49
+ "level": "INFO",
50
+ "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
51
+ }
52
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "uuid": "42597aa6-679e-4e63-8de4-31206ad5b1e6",
3
+ "server": {
4
+ "host": "0.0.0.0",
5
+ "port": 20000,
6
+ "protocol": "http",
7
+ "debug": false,
8
+ "log_level": "INFO"
9
+ },
10
+ "logging": {
11
+ "level": "INFO",
12
+ "file": null,
13
+ "log_dir": "./logs",
14
+ "log_file": "mcp_proxy_adapter.log",
15
+ "max_size": 10,
16
+ "backup_count": 5,
17
+ "console_output": true,
18
+ "json_format": false
19
+ },
20
+ "security": {
21
+ "enabled": false,
22
+ "tokens": {},
23
+ "roles": {},
24
+ "roles_file": null
25
+ },
26
+ "debug": {
27
+ "enabled": false,
28
+ "log_level": "DEBUG",
29
+ "trace_requests": false,
30
+ "trace_responses": false
31
+ },
32
+ "transport": {
33
+ "type": "http",
34
+ "port": null,
35
+ "verify_client": false,
36
+ "chk_hostname": false
37
+ }
38
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "server": {
3
+ "host": "http://localhost",
4
+ "port": 8001
5
+ },
6
+ "auth": {
7
+ "method": "none"
8
+ },
9
+ "ssl": {
10
+ "enabled": false
11
+ }
12
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "server": {
3
+ "host": "localhost",
4
+ "port": 8001,
5
+ "base_url": "http://localhost:8001"
6
+ },
7
+ "timeout": 30,
8
+ "retry_attempts": 3,
9
+ "retry_delay": 1,
10
+ "auth": {
11
+ "method": "none",
12
+ "api_key": {
13
+ "key": null,
14
+ "header": "X-API-Key"
15
+ },
16
+ "jwt": {
17
+ "username": null,
18
+ "password": null,
19
+ "secret": null,
20
+ "expiry_hours": 24
21
+ },
22
+ "certificate": {
23
+ "enabled": false,
24
+ "cert_file": null,
25
+ "key_file": null,
26
+ "ca_cert_file": null
27
+ },
28
+ "basic": {
29
+ "username": null,
30
+ "password": null
31
+ }
32
+ },
33
+ "ssl": {
34
+ "enabled": false,
35
+ "verify": true,
36
+ "check_hostname": true,
37
+ "cert_file": null,
38
+ "key_file": null,
39
+ "ca_cert_file": null,
40
+ "client_cert_required": false
41
+ },
42
+ "security": {
43
+ "enabled": false,
44
+ "roles_enabled": false,
45
+ "roles_file": null
46
+ },
47
+ "logging": {
48
+ "enabled": false,
49
+ "level": "INFO",
50
+ "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
51
+ }
52
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "server": {
3
+ "host": "http://localhost",
4
+ "port": 8001
5
+ },
6
+ "auth": {
7
+ "method": "none"
8
+ },
9
+ "ssl": {
10
+ "enabled": false
11
+ }
12
+ }