embed-client 4.0.87__tar.gz → 4.0.92__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 (97) hide show
  1. {embed_client-4.0.87/embed_client.egg-info → embed_client-4.0.92}/PKG-INFO +1 -1
  2. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/__init__.py +1 -1
  3. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/_version.py +1 -1
  4. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/adapter_config_factory.py +2 -1
  5. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/adapter_config_normalizer.py +4 -2
  6. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/adapter_generator_bridge.py +4 -2
  7. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/auth.py +2 -0
  8. embed_client-4.0.92/embed_client/cli.py +183 -0
  9. embed_client-4.0.92/embed_client/cli_core.py +117 -0
  10. embed_client-4.0.92/embed_client/cli_core_queue.py +101 -0
  11. embed_client-4.0.92/embed_client/cli_core_support.py +69 -0
  12. embed_client-4.0.92/embed_client/cli_core_vectorize.py +179 -0
  13. embed_client-4.0.87/embed_client/cli.py → embed_client-4.0.92/embed_client/cli_parser.py +41 -181
  14. embed_client-4.0.92/embed_client/client_factory.py +28 -0
  15. embed_client-4.0.92/embed_client/client_factory_config.py +251 -0
  16. embed_client-4.0.92/embed_client/client_factory_core.py +101 -0
  17. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/client_factory_helpers.py +1 -1
  18. embed_client-4.0.92/embed_client/client_factory_modes.py +165 -0
  19. embed_client-4.0.92/embed_client/client_factory_types.py +12 -0
  20. embed_client-4.0.92/embed_client/config.py +228 -0
  21. embed_client-4.0.92/embed_client/config_configure.py +90 -0
  22. embed_client-4.0.92/embed_client/config_generator.py +297 -0
  23. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/config_generator_cli.py +4 -1
  24. embed_client-4.0.92/embed_client/config_generator_http.py +127 -0
  25. embed_client-4.0.92/embed_client/config_generator_https.py +153 -0
  26. embed_client-4.0.92/embed_client/config_generator_mtls.py +113 -0
  27. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/config_presets.py +14 -17
  28. embed_client-4.0.92/embed_client/config_shortcuts.py +108 -0
  29. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/config_validator.py +6 -3
  30. embed_client-4.0.92/embed_client/config_validator_cli.py +144 -0
  31. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/demo_security_cli.py +46 -12
  32. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/embed_file_output_validate.py +12 -2
  33. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/embed_file_status_store.py +1 -0
  34. embed_client-4.0.92/embed_client/embedding_client.py +323 -0
  35. embed_client-4.0.92/embed_client/embedding_client_commands.py +165 -0
  36. embed_client-4.0.92/embed_client/embedding_client_embed.py +266 -0
  37. embed_client-4.0.92/embed_client/embedding_client_file.py +397 -0
  38. embed_client-4.0.92/embed_client/embedding_client_file_status.py +141 -0
  39. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/embedding_client_helpers.py +12 -6
  40. embed_client-4.0.92/embed_client/embedding_client_jobs.py +287 -0
  41. embed_client-4.0.92/embed_client/embedding_client_limits.py +155 -0
  42. embed_client-4.0.92/embed_client/embedding_client_models.py +147 -0
  43. embed_client-4.0.92/embed_client/embedding_client_support.py +300 -0
  44. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/example_async_usage.py +144 -127
  45. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/example_async_usage_demo.py +8 -4
  46. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/example_async_usage_ru.py +142 -124
  47. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/example_async_usage_ru_demo.py +40 -14
  48. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/exceptions.py +4 -0
  49. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/json_embed_file_preflight.py +24 -13
  50. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/local_json_embed_file.py +2 -5
  51. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/md_embed_file_prep.py +8 -4
  52. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/response_normalizer.py +6 -3
  53. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/response_parsers.py +28 -30
  54. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/security_cli.py +65 -47
  55. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/security_cli_core.py +1 -0
  56. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/ssl_examples.py +8 -4
  57. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/ssl_manager.py +1 -0
  58. {embed_client-4.0.87 → embed_client-4.0.92/embed_client.egg-info}/PKG-INFO +1 -1
  59. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client.egg-info/SOURCES.txt +21 -0
  60. embed_client-4.0.87/embed_client/cli_core.py +0 -427
  61. embed_client-4.0.87/embed_client/client_factory.py +0 -515
  62. embed_client-4.0.87/embed_client/config.py +0 -408
  63. embed_client-4.0.87/embed_client/config_generator.py +0 -652
  64. embed_client-4.0.87/embed_client/config_validator_cli.py +0 -141
  65. embed_client-4.0.87/embed_client/embedding_client.py +0 -1933
  66. {embed_client-4.0.87 → embed_client-4.0.92}/CONFIGURATION.md +0 -0
  67. {embed_client-4.0.87 → embed_client-4.0.92}/LICENSE +0 -0
  68. {embed_client-4.0.87 → embed_client-4.0.92}/MANIFEST.in +0 -0
  69. {embed_client-4.0.87 → embed_client-4.0.92}/README.md +0 -0
  70. {embed_client-4.0.87 → embed_client-4.0.92}/docs/SERVER_MODES_AND_CLIENT.md +0 -0
  71. {embed_client-4.0.87 → embed_client-4.0.92}/docs/api_format.md +0 -0
  72. {embed_client-4.0.87 → embed_client-4.0.92}/docs/client_integration_guide.md +0 -0
  73. {embed_client-4.0.87 → embed_client-4.0.92}/docs/error_handling_complete.md +0 -0
  74. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/__main__.py +0 -0
  75. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/client_factory_examples.py +0 -0
  76. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/config_defaults.py +0 -0
  77. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/config_examples.py +0 -0
  78. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/constants.py +0 -0
  79. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/demo_cli.py +0 -0
  80. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client/identifier_types.py +0 -0
  81. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client.egg-info/dependency_links.txt +0 -0
  82. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client.egg-info/entry_points.txt +0 -0
  83. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client.egg-info/requires.txt +0 -0
  84. {embed_client-4.0.87 → embed_client-4.0.92}/embed_client.egg-info/top_level.txt +0 -0
  85. {embed_client-4.0.87 → embed_client-4.0.92}/examples/README.md +0 -0
  86. {embed_client-4.0.87 → embed_client-4.0.92}/examples/__init__.py +0 -0
  87. {embed_client-4.0.87 → embed_client-4.0.92}/examples/async_testing_client_example.py +0 -0
  88. {embed_client-4.0.87 → embed_client-4.0.92}/examples/canonical_mtls_localhost_8001.py +0 -0
  89. {embed_client-4.0.87 → embed_client-4.0.92}/examples/configs/http_simple.json +0 -0
  90. {embed_client-4.0.87 → embed_client-4.0.92}/examples/configs/https_token.json +0 -0
  91. {embed_client-4.0.87 → embed_client-4.0.92}/examples/configs/mtls_roles.json +0 -0
  92. {embed_client-4.0.87 → embed_client-4.0.92}/examples/data/embed_file_json_array_sample.json +0 -0
  93. {embed_client-4.0.87 → embed_client-4.0.92}/examples/embed_file_json_local.py +0 -0
  94. {embed_client-4.0.87 → embed_client-4.0.92}/examples/security_examples.py +0 -0
  95. {embed_client-4.0.87 → embed_client-4.0.92}/examples/security_examples_ru.py +0 -0
  96. {embed_client-4.0.87 → embed_client-4.0.92}/pyproject.toml +0 -0
  97. {embed_client-4.0.87 → embed_client-4.0.92}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: embed-client
3
- Version: 4.0.87
3
+ Version: 4.0.92
4
4
  Summary: Async client for the Embedding Service API. Canonical class: EmbeddingClient (JSON-RPC via mcp-proxy-adapter >=8.11.16).
5
5
  Author-email: Vasiliy Zdanovskiy <vasilyvz@gmail.com>
6
6
  License-Expression: MIT
@@ -9,7 +9,7 @@ Author: Vasiliy Zdanovskiy
9
9
  email: vasilyvz@gmail.com
10
10
  """
11
11
 
12
- from embed_client._version import __version__
12
+ from embed_client._version import __version__ # noqa: F401
13
13
 
14
14
  from embed_client.auth import ClientAuthManager
15
15
  from embed_client.config import ClientConfig
@@ -1,3 +1,3 @@
1
1
  """Authoritative release version for the bundled server and client."""
2
2
 
3
- __version__ = "4.0.87"
3
+ __version__ = "4.0.92"
@@ -1,7 +1,8 @@
1
1
  """
2
2
  Adapter Configuration Factory
3
3
 
4
- This module provides translation from ClientConfig to mcp_proxy_adapter JsonRpcClient parameters.
4
+ This module provides translation from ClientConfig to mcp_proxy_adapter JsonRpcClient
5
+ parameters.
5
6
 
6
7
  Author: Vasiliy Zdanovskiy
7
8
  email: vasilyvz@gmail.com
@@ -37,7 +37,8 @@ def client_to_adapter_format(
37
37
  ssl_config = config_data.get("ssl", {})
38
38
  auth_config = config_data.get("auth", {})
39
39
 
40
- # Cert paths: embed-client uses ssl.cert_file / auth.certificate (keep as-is; adapter uses cwd for abspath)
40
+ # Cert paths: embed-client uses ssl.cert_file / auth.certificate (keep as-is;
41
+ # adapter uses cwd for abspath)
41
42
  cert_file = ssl_config.get("cert_file") or (
42
43
  auth_config.get("certificate") or {}
43
44
  ).get("cert_file")
@@ -114,7 +115,8 @@ def map_adapter_errors_to_client(
114
115
 
115
116
  Translates section/key (e.g. server.ssl.cert) to client names (ssl.cert_file).
116
117
  """
117
- from mcp_proxy_adapter.core.validation.validation_result import ValidationResult # type: ignore[import-untyped]
118
+ # type: ignore[import-untyped]
119
+ from mcp_proxy_adapter.core.validation.validation_result import ValidationResult
118
120
 
119
121
  result: List[str] = []
120
122
  for r in adapter_errors:
@@ -17,7 +17,8 @@ from pathlib import Path
17
17
  from typing import Any, Dict, Optional
18
18
 
19
19
  try:
20
- from mcp_proxy_adapter.core.config.simple_config_generator import ( # type: ignore[import-untyped]
20
+ # type: ignore[import-untyped]
21
+ from mcp_proxy_adapter.core.config.simple_config_generator import (
21
22
  SimpleConfigGenerator,
22
23
  )
23
24
 
@@ -120,7 +121,8 @@ def generate_client_config_via_adapter(
120
121
  """
121
122
  if not _ADAPTER_AVAILABLE or SimpleConfigGenerator is None:
122
123
  raise RuntimeError(
123
- "mcp_proxy_adapter is not available; install it to use adapter-based generator"
124
+ "mcp_proxy_adapter is not available; install it to use adapter-based "
125
+ "generator"
124
126
  )
125
127
 
126
128
  if protocol == "mtls" and not ca_cert_file:
@@ -18,6 +18,7 @@ class AuthenticationError(Exception):
18
18
  """Raised when authentication fails."""
19
19
 
20
20
  def __init__(self, message: str, error_code: int = 401):
21
+ """Initialise the instance."""
21
22
  self.message = message
22
23
  self.error_code = error_code
23
24
  super().__init__(self.message)
@@ -33,6 +34,7 @@ class AuthResult:
33
34
  roles: Optional[List[str]] = None,
34
35
  error: Optional[str] = None,
35
36
  ):
37
+ """Initialise the instance."""
36
38
  self.success = success
37
39
  self.user_id = user_id
38
40
  self.roles = roles or []
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ CLI Application for Text Vectorization
4
+ Command-line interface for embedding text using embed-client.
5
+
6
+ This CLI is fully based on the embed-client library and uses:
7
+ - ClientFactory for client creation
8
+ - ClientConfig for configuration management
9
+ - response_parsers for data extraction
10
+ - All authentication methods (API Key, JWT, Basic, Certificate)
11
+ - Queue management commands
12
+
13
+ Author: Vasiliy Zdanovskiy
14
+ email: vasilyvz@gmail.com
15
+ """
16
+
17
+ import argparse
18
+ import asyncio
19
+ import sys
20
+ from typing import Any, Awaitable, Callable, Dict # noqa: F401
21
+
22
+ from embed_client.config import ClientConfig
23
+ from embed_client.cli_core import VectorizationCLI, create_config_from_args
24
+ from embed_client.cli_parser import _device_arg, build_parser # noqa: F401
25
+ from embed_client.constants import DEFAULT_POLL_INTERVAL
26
+
27
+
28
+ def _read_texts_file(file_path: str) -> list[str]:
29
+ """Read the non-empty stripped lines of *file_path* (runs in an executor)."""
30
+ with open(file_path, "r", encoding="utf-8") as f:
31
+ return [line.strip() for line in f if line.strip()]
32
+
33
+
34
+ async def _cmd_vectorize(cli: VectorizationCLI, args: argparse.Namespace) -> bool:
35
+ """vectorize: texts from the command line and/or a file."""
36
+ texts = args.texts
37
+ if args.file:
38
+ # Use async file reading to avoid blocking the event loop
39
+ # Read file in executor to avoid blocking
40
+ loop = asyncio.get_event_loop()
41
+ file_texts = await loop.run_in_executor(None, _read_texts_file, args.file)
42
+ texts.extend(file_texts)
43
+
44
+ if not texts:
45
+ print("❌ No texts provided", file=sys.stderr)
46
+ return False
47
+
48
+ embeddings = await cli.vectorize_texts(
49
+ texts,
50
+ args.format,
51
+ args.full_data,
52
+ timeout=getattr(args, "wait_timeout", None),
53
+ model=getattr(args, "model", None),
54
+ dimension=getattr(args, "dimension", None),
55
+ error_policy=getattr(args, "error_policy", "continue"),
56
+ device=getattr(args, "device", None),
57
+ )
58
+ return embeddings is not None
59
+
60
+
61
+ async def _cmd_embed_file_json(cli: VectorizationCLI, args: argparse.Namespace) -> bool:
62
+ """embed-file-json: upload a local JSON array file and embed it server-side."""
63
+ return await cli.embed_file_local_json(
64
+ args.json_path,
65
+ max_block_bytes=getattr(args, "max_block_bytes", None),
66
+ upload_filename=getattr(args, "upload_filename", None),
67
+ wait_timeout=getattr(args, "embed_file_wait_timeout", None),
68
+ download_to=getattr(args, "download_to", None),
69
+ skip_download=bool(getattr(args, "skip_download", False)),
70
+ model=getattr(args, "model", None),
71
+ dimension=getattr(args, "dimension", None),
72
+ device=getattr(args, "device", None),
73
+ error_policy=getattr(args, "error_policy", "continue"),
74
+ show_progress=bool(getattr(args, "show_progress", False)),
75
+ )
76
+
77
+
78
+ async def _cmd_queue_list(cli: VectorizationCLI, args: argparse.Namespace) -> bool:
79
+ """queue-list: list queued commands."""
80
+ return await cli.queue_list(
81
+ getattr(args, "status", None), getattr(args, "limit", None)
82
+ )
83
+
84
+
85
+ async def _cmd_queue_wait(cli: VectorizationCLI, args: argparse.Namespace) -> bool:
86
+ """queue-wait: wait for a job to complete."""
87
+ return await cli.queue_wait(
88
+ args.job_id,
89
+ timeout=getattr(args, "timeout", 60.0),
90
+ poll_interval=getattr(args, "poll_interval", DEFAULT_POLL_INTERVAL),
91
+ )
92
+
93
+
94
+ _COMMAND_HANDLERS: Dict[
95
+ str, Callable[[VectorizationCLI, argparse.Namespace], Awaitable[bool]]
96
+ ] = {
97
+ "vectorize": _cmd_vectorize,
98
+ "embed-file-json": _cmd_embed_file_json,
99
+ "health": lambda cli, args: cli.health_check(),
100
+ "help": lambda cli, args: cli.get_help(getattr(args, "help_command", None)),
101
+ "commands": lambda cli, args: cli.get_commands(),
102
+ "models": lambda cli, args: cli.get_models(),
103
+ "timing-stats": lambda cli, args: cli.get_timing_stats(
104
+ getattr(args, "file_path", None)
105
+ ),
106
+ "queue-list": _cmd_queue_list,
107
+ "queue-status": lambda cli, args: cli.queue_status(args.job_id),
108
+ "queue-cancel": lambda cli, args: cli.queue_cancel(args.job_id),
109
+ "queue-wait": _cmd_queue_wait,
110
+ "queue-logs": lambda cli, args: cli.queue_logs(args.job_id),
111
+ }
112
+
113
+
114
+ def _load_config(args: argparse.Namespace) -> tuple:
115
+ """Return (config, config_dict): the config file, or the command-line options."""
116
+ config = None
117
+ config_dict = None
118
+ if args.config:
119
+ # Load from config file using ClientConfig
120
+ config = ClientConfig(args.config)
121
+ config.load_config()
122
+ if getattr(args, "insecure", False):
123
+ # --insecure overrides config file: disable TLS hostname/cert
124
+ # verification for HTTPS and WebSocket connections.
125
+ config.set("ssl.check_hostname", False)
126
+ else:
127
+ # Create config from command line arguments
128
+ config_dict = create_config_from_args(args)
129
+ return config, config_dict
130
+
131
+
132
+ async def main():
133
+ """Main CLI function."""
134
+ parser = build_parser()
135
+
136
+ args = parser.parse_args()
137
+
138
+ if not args.command:
139
+ parser.print_help()
140
+ return 1
141
+
142
+ if args.command == "prepare-embed-file-json":
143
+ from embed_client.md_embed_file_prep import prepare_markdown_cli_main
144
+
145
+ return prepare_markdown_cli_main(args)
146
+
147
+ config, config_dict = _load_config(args)
148
+
149
+ # Create CLI instance
150
+ cli = VectorizationCLI()
151
+
152
+ try:
153
+ # Connect to service
154
+ if not await cli.connect(config=config, config_dict=config_dict):
155
+ return 1
156
+
157
+ # Execute command
158
+ handler = _COMMAND_HANDLERS.get(args.command)
159
+ if handler is not None and not await handler(cli, args):
160
+ return 1
161
+
162
+ return 0
163
+
164
+ except KeyboardInterrupt:
165
+ print("\n🛑 Interrupted by user", file=sys.stderr)
166
+ return 1
167
+ except Exception as e:
168
+ print(f"❌ Error: {e}", file=sys.stderr)
169
+ import traceback
170
+
171
+ traceback.print_exc()
172
+ return 1
173
+ finally:
174
+ await cli.disconnect()
175
+
176
+
177
+ def cli_main():
178
+ """Synchronous entry point for CLI command."""
179
+ return asyncio.run(main())
180
+
181
+
182
+ if __name__ == "__main__":
183
+ sys.exit(cli_main())
@@ -0,0 +1,117 @@
1
+ """
2
+ Core implementation of the embed-client CLI.
3
+
4
+ Provides the `VectorizationCLI` class and configuration helpers used by the
5
+ user-facing `embed_client.cli` entry point.
6
+
7
+ Author: Vasiliy Zdanovskiy
8
+ email: vasilyvz@gmail.com
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import json
14
+ import sys
15
+ from typing import Any, Dict, Optional
16
+
17
+ from embed_client.embedding_client import EmbeddingClient
18
+ from embed_client.client_factory import ClientFactory
19
+ from embed_client.config import ClientConfig
20
+
21
+ from embed_client.cli_core_support import ( # noqa: F401
22
+ create_config_from_args,
23
+ )
24
+
25
+
26
+ from embed_client.cli_core_queue import _VectorizationCLIQueueMixin
27
+
28
+ from embed_client.cli_core_vectorize import _VectorizationCLIVectorizeMixin
29
+
30
+
31
+ class VectorizationCLI(_VectorizationCLIQueueMixin, _VectorizationCLIVectorizeMixin):
32
+ """CLI application for text vectorization using embed-client library.
33
+
34
+ This class encapsulates the core logic of the `embed-vectorize` command,
35
+ including connection management, health checks, embedding requests, and
36
+ queue operations. It relies exclusively on `EmbeddingClient`
37
+ and related helpers from the embed-client package.
38
+ """
39
+
40
+ def __init__(self) -> None:
41
+ """Initialize a new VectorizationCLI instance."""
42
+ self.client: Optional[EmbeddingClient] = None
43
+
44
+ async def connect(
45
+ self,
46
+ config: Optional[ClientConfig] = None,
47
+ config_dict: Optional[Dict[str, Any]] = None,
48
+ ) -> bool:
49
+ """Connect to the embedding service using provided configuration.
50
+
51
+ The client is created via `ClientFactory` or directly from a
52
+ `ClientConfig` / configuration dictionary. All low-level transport and
53
+ authentication details are handled by the embed-client library.
54
+
55
+ Args:
56
+ config: Optional `ClientConfig` instance.
57
+ config_dict: Optional raw configuration dictionary.
58
+
59
+ Returns:
60
+ True if connection was established successfully, False otherwise.
61
+ """
62
+ try:
63
+ if config is not None:
64
+ self.client = EmbeddingClient.from_config(config)
65
+ elif config_dict is not None:
66
+ from embed_client.embedding_client import (
67
+ embedding_client_from_config_dict,
68
+ )
69
+
70
+ self.client = embedding_client_from_config_dict(config_dict)
71
+ else:
72
+ # Use ClientFactory.from_environment() as fallback
73
+ self.client = ClientFactory.from_environment()
74
+
75
+ await self.client.__aenter__()
76
+ return True
77
+ except Exception as exc: # noqa: BLE001
78
+ print(f"❌ Failed to connect: {exc}", file=sys.stderr)
79
+ return False
80
+
81
+ async def disconnect(self) -> None:
82
+ """Close the underlying client connection if it exists."""
83
+ if self.client is not None:
84
+ await self.client.close()
85
+
86
+ async def health_check(self) -> bool:
87
+ """Perform a health check against the embedding service."""
88
+ try:
89
+ assert self.client is not None
90
+ result = await self.client.health()
91
+ print(json.dumps(result, indent=2))
92
+ return True
93
+ except Exception as exc: # noqa: BLE001
94
+ print(f"❌ Health check failed: {exc}", file=sys.stderr)
95
+ return False
96
+
97
+ async def get_models(self) -> bool:
98
+ """Fetch and print available embedding models from the service."""
99
+ try:
100
+ assert self.client is not None
101
+ result = await self.client.models()
102
+ print(json.dumps(result, indent=2))
103
+ return True
104
+ except Exception as exc: # noqa: BLE001
105
+ print(f"❌ Failed to get models: {exc}", file=sys.stderr)
106
+ return False
107
+
108
+ async def get_timing_stats(self, file_path: Optional[str] = None) -> bool:
109
+ """Fetch and print timing statistics from the service."""
110
+ try:
111
+ assert self.client is not None
112
+ result = await self.client.timing_stats(file_path=file_path)
113
+ print(json.dumps(result, indent=2))
114
+ return True
115
+ except Exception as exc: # noqa: BLE001
116
+ print(f"❌ Failed to get timing stats: {exc}", file=sys.stderr)
117
+ return False
@@ -0,0 +1,101 @@
1
+ """VectorizationCLI queue methods (mixin of :mod:`embed_client.cli_core`)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from embed_client.constants import DEFAULT_POLL_INTERVAL
6
+ from typing import Optional
7
+ import json
8
+ import sys
9
+
10
+
11
+ class _VectorizationCLIQueueMixin:
12
+ """VectorizationCLI queue methods."""
13
+
14
+ async def queue_list(
15
+ self, status: Optional[str] = None, limit: Optional[int] = None
16
+ ) -> bool:
17
+ """List queued commands."""
18
+ try:
19
+ assert self.client is not None
20
+ result = await self.client.list_queued_commands(status=status, limit=limit)
21
+ print(json.dumps(result, indent=2))
22
+ return True
23
+ except Exception as exc: # noqa: BLE001
24
+ print(f"❌ Failed to list queue: {exc}", file=sys.stderr)
25
+ return False
26
+
27
+ async def queue_status(self, job_id: str) -> bool:
28
+ """Get the status of a specific job."""
29
+ try:
30
+ assert self.client is not None
31
+ result = await self.client.job_status(job_id)
32
+ print(json.dumps(result, indent=2))
33
+ return True
34
+ except Exception as exc: # noqa: BLE001
35
+ print(f"❌ Failed to get job status: {exc}", file=sys.stderr)
36
+ return False
37
+
38
+ async def queue_cancel(self, job_id: str) -> bool:
39
+ """Cancel a queued or running job."""
40
+ try:
41
+ assert self.client is not None
42
+ result = await self.client.cancel_command(job_id)
43
+ print(json.dumps(result, indent=2))
44
+ return True
45
+ except Exception as exc: # noqa: BLE001
46
+ print(f"❌ Failed to cancel job: {exc}", file=sys.stderr)
47
+ return False
48
+
49
+ async def queue_wait(
50
+ self,
51
+ job_id: str,
52
+ timeout: float = 60.0,
53
+ poll_interval: float = DEFAULT_POLL_INTERVAL,
54
+ ) -> bool:
55
+ """Wait for completion of a specific job."""
56
+ try:
57
+ assert self.client is not None
58
+ result = await self.client.wait_for_job(
59
+ job_id, timeout=timeout, poll_interval=poll_interval
60
+ )
61
+ print(json.dumps(result, indent=2))
62
+ return True
63
+ except Exception as exc: # noqa: BLE001
64
+ print(f"❌ Failed to wait for job: {exc}", file=sys.stderr)
65
+ return False
66
+
67
+ async def queue_logs(self, job_id: str) -> bool:
68
+ """Fetch logs for a specific job."""
69
+ try:
70
+ assert self.client is not None
71
+ result = await self.client.get_job_logs(job_id)
72
+ print(json.dumps(result, indent=2))
73
+ return True
74
+ except Exception as exc: # noqa: BLE001
75
+ print(f"❌ Failed to get job logs: {exc}", file=sys.stderr)
76
+ return False
77
+
78
+ async def get_help(self, command: Optional[str] = None) -> bool:
79
+ """Fetch help information from the embedding service."""
80
+ try:
81
+ assert self.client is not None
82
+ if command:
83
+ result = await self.client.cmd("help", params={"command": command})
84
+ else:
85
+ result = await self.client.cmd("help")
86
+ print(json.dumps(result, indent=2))
87
+ return True
88
+ except Exception as exc: # noqa: BLE001
89
+ print(f"❌ Help request failed: {exc}", file=sys.stderr)
90
+ return False
91
+
92
+ async def get_commands(self) -> bool:
93
+ """List all available commands from the embedding service."""
94
+ try:
95
+ assert self.client is not None
96
+ result = await self.client.list_commands()
97
+ print(json.dumps(result, indent=2))
98
+ return True
99
+ except Exception as exc: # noqa: BLE001
100
+ print(f"❌ Commands request failed: {exc}", file=sys.stderr)
101
+ return False
@@ -0,0 +1,69 @@
1
+ """cli_core - support part of :mod:`embed_client.cli_core`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict
6
+ import json
7
+ import sys
8
+
9
+
10
+ def _embed_file_ws_progress_stderr(msg: Dict[str, Any]) -> None:
11
+ """Print one WebSocket/status JSON object per line to stderr (embed_file wait)."""
12
+ print(json.dumps(msg, ensure_ascii=False), file=sys.stderr, flush=True)
13
+
14
+
15
+ def create_config_from_args(args: Any) -> Dict[str, Any]:
16
+ """Create a configuration dictionary from parsed CLI arguments.
17
+
18
+ This helper mirrors the shape of the JSON configuration files used by
19
+ `ClientConfig` and `ClientFactory`, allowing the CLI to construct a
20
+ `ClientConfig` instance without requiring callers to manage JSON files.
21
+
22
+ The ``--insecure`` (``--no-check-hostname``) flag maps to
23
+ ``ssl.check_hostname = False``, which the library propagates as
24
+ ``check_hostname=False`` to both the HTTPS transport and the WebSocket
25
+ (wss) SSL context. Default (no flag) keeps strict TLS verification.
26
+ """
27
+ insecure = bool(getattr(args, "insecure", False))
28
+ config: Dict[str, Any] = {
29
+ "server": {"host": args.host, "port": args.port},
30
+ "auth": {"method": "none"},
31
+ "ssl": {"enabled": False, "check_hostname": not insecure},
32
+ "client": {"timeout": getattr(args, "timeout", 30.0)},
33
+ }
34
+
35
+ # Add authentication if specified
36
+ if getattr(args, "api_key", None):
37
+ config["auth"]["method"] = "api_key"
38
+ config["auth"]["api_keys"] = {"user": args.api_key}
39
+ if getattr(args, "api_key_header", None):
40
+ config["auth"]["api_key_header"] = args.api_key_header
41
+ elif getattr(args, "jwt_secret", None):
42
+ config["auth"]["method"] = "jwt"
43
+ config["auth"]["jwt"] = {
44
+ "secret": args.jwt_secret,
45
+ "username": getattr(args, "jwt_username", ""),
46
+ "password": getattr(args, "jwt_password", ""),
47
+ }
48
+ elif getattr(args, "basic_username", None):
49
+ config["auth"]["method"] = "basic"
50
+ config["auth"]["basic"] = {
51
+ "username": args.basic_username,
52
+ "password": getattr(args, "basic_password", ""),
53
+ }
54
+
55
+ # Add SSL if specified
56
+ if (
57
+ getattr(args, "ssl", False)
58
+ or getattr(args, "cert_file", None)
59
+ or getattr(args, "key_file", None)
60
+ ):
61
+ config["ssl"]["enabled"] = True
62
+ if getattr(args, "cert_file", None):
63
+ config["ssl"]["cert_file"] = args.cert_file
64
+ if getattr(args, "key_file", None):
65
+ config["ssl"]["key_file"] = args.key_file
66
+ if getattr(args, "ca_cert_file", None):
67
+ config["ssl"]["ca_cert_file"] = args.ca_cert_file
68
+
69
+ return config