Metadata-Version: 2.4
Name: acty-gigachat
Version: 0.1.0
Summary: GigaChat executor for acty
Project-URL: Homepage, https://github.com/conspol/acty-gigachat
Project-URL: Repository, https://github.com/conspol/acty-gigachat
Project-URL: Issues, https://github.com/conspol/acty-gigachat/issues
Maintainer-email: Konstantin Polev <70580603+conspol@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Keywords: gigachat,langchain,sessions,telemetry,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Requires-Dist: acty-core<0.2.0,>=0.1.0
Requires-Dist: acty<0.2.0,>=0.1.0
Requires-Dist: langchain-gigachat>=0.3.12
Provides-Extra: dev
Requires-Dist: acty<0.2.0,>=0.1.0; extra == 'dev'
Requires-Dist: build>=1.2.2; extra == 'dev'
Requires-Dist: gigachat>=0.1.43; extra == 'dev'
Requires-Dist: httpcore>=1.0.9; extra == 'dev'
Requires-Dist: httpx>=0.28.1; extra == 'dev'
Requires-Dist: opentelemetry-sdk>=1.39.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
Requires-Dist: pytest>=9.0.0; extra == 'dev'
Requires-Dist: twine>=5.1.1; extra == 'dev'
Description-Content-Type: text/markdown

# acty-gigachat

`acty-gigachat` provides a `GigaChatExecutor` implementation for Acty. It
adapts `langchain-gigachat` chat models to the Acty executor interface and adds
session-aware behavior for GigaChat prefix-caching workflows.

## Install

```bash
pip install acty-gigachat
```

For local development:

```bash
pip install -e .[dev]
```

## Usage

```python
import asyncio

from acty import ActyEngine, EngineConfig
from acty_gigachat import GigaChatExecutor
from langchain_gigachat.chat_models import GigaChat


async def main() -> None:
    model = GigaChat(credentials="YOUR_AUTHORIZATION_KEY", verify_ssl_certs=False)
    engine = ActyEngine(
        executor=GigaChatExecutor(model=model),
        config=EngineConfig(primer_workers=1, follower_workers=1),
    )
    try:
        submission = await engine.submit_group(
            "demo",
            {"input": "Hello!", "invoke_kwargs": {"temperature": 0.2}},
            [],
        )
        if submission.primer is not None:
            result = await submission.primer
            print(result.output)
    finally:
        await engine.close()


asyncio.run(main())
```

Payloads may provide `messages`, `input`, or `prompt`. The executor forwards an
optional `invoke_kwargs` dictionary to the model.

## Session Handling

`GigaChatExecutor` uses the GigaChat SDK `session_id_cvar` context variable to
control the `X-Session-ID` header during model calls.

- if `Job.context["cache"]["provider_ref"]` is present, the executor reuses it
- otherwise, it creates a per-group fallback session id
- session-invalid failures rotate to a new session id
- transient failures reuse the current session id

This makes the executor suitable for Acty cache flows where a primer attaches a
provider reference and followers reuse it later.

## Telemetry

The executor can enrich the active OpenTelemetry/OpenInference LLM span with:

- Acty correlation identifiers
- bounded input message attributes
- cached prompt token usage when the model response exposes it

This is enabled by default and respects the configured telemetry privacy gates.

## Development

- tests live under `tests/`
- the repo includes unit tests, session lifecycle tests, and Acty engine
  integration coverage for telemetry, retry, and TTL/session rotation behavior
- the package depends directly on both `acty` and `acty-core` because it imports
  symbols from both at runtime
