Metadata-Version: 2.4
Name: acty-langchain
Version: 0.1.0
Summary: LangChain helpers for acty payloads
Project-URL: Homepage, https://github.com/conspol/acty-langchain
Project-URL: Repository, https://github.com/conspol/acty-langchain
Project-URL: Issues, https://github.com/conspol/acty-langchain/issues
Maintainer-email: Konstantin Polev <70580603+conspol@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Keywords: langchain,messages,retry,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: langchain-core>=0.3.0
Requires-Dist: tenacity>=8.2.0
Provides-Extra: dev
Requires-Dist: acty<0.2.0,>=0.1.0; extra == 'dev'
Requires-Dist: build>=1.2.2; 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-langchain

`acty-langchain` provides LangChain-specific helpers for the Acty ecosystem:
message serialization, repair hints for malformed JSON outputs, and runnable
executor utilities that integrate with `acty`.

## Install

Runtime helpers only:

```bash
pip install acty-langchain
```

If you want to run LangChain runnables through `ActyEngine`:

```bash
pip install acty acty-langchain
```

For local development:

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

## Message Payload Helpers

```python
from langchain_core.messages import HumanMessage
from acty_langchain import messages_to_acty_payload, messages_from_acty_payload

payload = messages_to_acty_payload(
    [HumanMessage(content="hello")],
    payload={"exec_id": "chat"},
)

roundtrip = messages_from_acty_payload(payload)
```

These helpers convert LangChain messages into JSON-safe payload structures that
can be stored, retried, or cached inside Acty workflows.

## Runnable Payload Shape

The runnable executor accepts payloads shaped like:

```python
{
    "runnable": my_chain,
    "input": {"question": "hi"},
}
```

Resolver-based execution can also use:

```python
{
    "exec_id": "qa",
    "input": {"question": "hi"},
}
```

## Runnable Execution

```python
from acty import ActyEngine, EngineConfig
from acty_langchain import LangChainRunnableExecutor, runnable_retry_factory

engine = ActyEngine(
    executor=LangChainRunnableExecutor(),
    config=EngineConfig(
        attempt_retry_policy=runnable_retry_factory(),
    ),
)
```

## JSON Repair Helpers

`acty-langchain` also includes repair utilities for invalid JSON responses:

```python
from acty_langchain import DefaultPromptedJsonRepairer

repairer = DefaultPromptedJsonRepairer(
    system_instruction="Return only valid JSON.",
    repair_request="Please repair the assistant output above.",
)
```

## Development

- tests live under `tests/`
- the package depends on `acty-core` at runtime
- tests also install `acty` so runnable executor integration can be exercised
