Metadata-Version: 2.4
Name: svo-client
Version: 3.1.0
Summary: Async client for SVO semantic chunker microservice.
Home-page: https://github.com/your_org/svo_client
Author: Vasiliy Zdanovskiy
Author-email: vasilyvz@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.0.0
Requires-Dist: chunk_metadata_adapter>=3.3.5
Requires-Dist: mcp-proxy-adapter>=8.10.12
Requires-Dist: embed-client>=3.1.9.3
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: httpx>=0.24.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# svo-client

Async Python client for the SVO semantic chunker. **Canonical API:** `SvoChunkerClient` (adapter / `JsonRpcClient` only).

## Install

```bash
pip install -e .
# or: pip install svo-client
```

## Quick start

```python
import asyncio
from svo_client import SvoChunkerClient

async def main():
    async with SvoChunkerClient(
        protocol="mtls",
        host="127.0.0.1",
        port=8009,
        cert="mtls_certificates/client/svo-chunker.crt",
        key="mtls_certificates/client/svo-chunker.key",
        ca="mtls_certificates/ca/ca.crt",
        check_hostname=False,
    ) as client:
        chunks = await client.chunk(
            text="Your text.",
            chunk_type="Comment",
            aggregation_mode="paragraph",
            respect_structural_blocks=True,
            language="en",
        )
        print(len(chunks))

asyncio.run(main())
```

## Current Chunker Parameters

- `chunk_type="Comment"` is passed as RPC field `type="Comment"` for comments, docstrings, or other pre-extracted blocks. The server owns the Comment keep-block policy.
- `aggregation_mode` is optional. Supported values are `"sentence"`, `"none"`, and `"paragraph"`. When omitted, the client does not send the field.
- `respect_structural_blocks` is optional. Use `True` or `False` to send `respect_structural_blocks`; omit it to preserve the server default.

```python
from svo_client import build_file_chunk_params
from svo_client.file_processor import file_chunk_from_local_path

chunks = await client.chunk(
    text="# module comment",
    chunk_type="Comment",
    aggregation_mode="paragraph",
    respect_structural_blocks=True,
)

batch = await client.chunk_batch(
    ["first paragraph", "second paragraph"],
    aggregation_mode="paragraph",
    respect_structural_blocks=False,
)

params = build_file_chunk_params(
    filename="comments.py",
    file_content_base64=encoded,
    chunk_type="Comment",
    aggregation_mode="paragraph",
    respect_structural_blocks=True,
)
result = await client.file_chunk(params)

result = await file_chunk_from_local_path(
    client,
    "comments.py",
    chunk_type="Comment",
    aggregation_mode="paragraph",
    respect_structural_blocks=True,
)
```

**CLI:** `svo-client` or `python -m svo_client` — thin wrapper; local file chunking orchestration is `file_chunk_from_local_path` in `svo_client.file_processor`. Text chunking: `chunk` (default) and `chunk text`; file chunking: `chunk file` or `file-chunk` (alias); **`ws`** prints inbound WebSocket JSON lines to stdout. **`--help`** lists all flags. **RPC discovery:** `svo-chunker` (`list` / `help` / `run`).

```bash
svo-client chunk text -i sample.txt -o out.json --format json --chunk-type Comment
svo-client file-chunk -i sample.md -o out.jsonl --aggregation-mode paragraph --respect-structural-blocks
svo-client file-chunk -i comments.py --no-download --chunk-type Comment --no-respect-structural-blocks
```

Configuration precedence (**CLI** → **`SVO_CHUNKER_CLIENT_*`** → **JSON**), **`--config`**, and CLI details (`ws`, **`--quiet-status`**, file-chunk status on stderr): [`svo_client/README.md`](svo_client/README.md).

## Tests

```bash
.venv/bin/python -m pytest tests/ -q
```

Live integration (chunker on `127.0.0.1:8009`): port must be listening or free for managed spawn; see `tests/conftest.py`.
