Metadata-Version: 2.4
Name: asymmetric-py
Version: 0.1.0
Summary: Lightweight Python SDK for the Asymmetric API
Project-URL: Homepage, https://github.com/asymmetric-dev/asymmetric-py
Project-URL: Repository, https://github.com/asymmetric-dev/asymmetric-py
Project-URL: Issues, https://github.com/asymmetric-dev/asymmetric-py/issues
Author: Asymmetric
License: PolyForm Noncommercial License 1.0.0
        
        Acceptance
        
        In order to get any license under these terms, you must agree
        to them as both strict obligations and conditions to all your
        licenses.
        
        Copyright License
        
        The licensor grants you a copyright license for the software to
        do everything you might do with the software that would otherwise
        infringe the licensor's copyright in it for any permitted purpose.
        
        Patent License
        
        The licensor grants you a patent license for the software that
        covers patent claims the licensor can license, or becomes able to
        license, that you would otherwise infringe by using the software
        for any permitted purpose.
        
        Noncommercial Purposes
        
        Any noncommercial purpose is a permitted purpose.
        
        Distribution
        
        You may distribute copies of the software.
        
        Conditions
        
        Your licenses are subject to the following conditions:
        
        No Trademark License
        
        Neither this license nor any other license granted under these
        terms gives you any right in the licensor's trademarks or any
        other rights in the licensor's name, logo, or brand.
        
        Notices
        
        You must ensure that anyone who gets a copy of any part of the
        software from you also gets a copy of these terms or a link to
        <https://polyformproject.org/licenses/noncommercial/1.0.0>.
        
        Changes
        
        You must not remove any copyright notice from the software.
        
        You must cause any modified files to carry prominent notices
        stating that you changed the files.
        
        No Compensation
        
        You may not use this software or provide it to others for
        compensation or other consideration.
        
        If you are already using this software for compensation or other
        consideration, you must stop.
        
        Excuse
        
        If anyone notifies you in writing that you have not complied with
        No Compensation, you can keep your license by taking all practical
        steps to comply within 32 days after the notice. Otherwise, your
        license ends immediately.
        
        Patent Defense
        
        If you make any written claim that the software infringes or
        contributes to infringement of any patent, your patent license
        for the software ends immediately. If your company makes such a
        claim, your patent license ends immediately for work on behalf of
        your company.
        
        Violations
        
        If you violate these terms, your licenses end immediately.
        
        No Liability
        
        As far as the law allows, the software comes as is, without any
        warranty or condition, and the licensor will not be liable to you
        for any damages arising out of these terms or the use or nature of
        the software, under any kind of legal claim.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: python-dotenv>=1.0
Description-Content-Type: text/markdown

asymmetric-py

## Install

```bash
pip install asymmetric-py
```

Or install from source:

```bash
git clone https://github.com/asymmetric-dev/asymmetric-py.git
cd asymmetric-py
pip install .
```

## Publishing

See [PUBLISH.md](PUBLISH.md).

## Usage

```python
from asymmetric import Asymmetric, GuardrailViolation

client = Asymmetric(api_key="sk_live_...")
```

### Guardrails ([example](examples/guardrails.py))

```python
try:
    response = client.chat.completions.create(
        model="openai/gpt-4o-mini",
        messages=[{"role": "user", "content": "Tell me about Caltech"}],
        guardrail_policy="Flag any content mentioning Caltech",
    )
    print(response.choices[0].message.content)
except GuardrailViolation as e:
    print(e.policy)
```

### Streaming ([example](examples/streaming.py))

```python
try:
    for chunk in client.chat.completions.create(
        model="openai/gpt-4o-mini",
        messages=[{"role": "user", "content": "Tell me about Caltech"}],
        guardrail_policy="Flag any content mentioning Caltech",
        stream=True,
    ):
        if chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="")
except GuardrailViolation as e:
    print(f"\nViolation: {e.policy}")
```

### Multiple policies ([example](examples/multiple_policies.py))

```python
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
    guardrail_policy=[
        "Flag any content promoting violence",
        "Flag any content containing profanity",
    ],
)
```

### Violation history ([example](examples/violations.py))

```python
violations = client.guardrails.list_violations()
for v in violations:
    print(v.timestamp, v.guardrail_policy)
```

### Finetuning ([example](examples/finetuning.py))

```python
# Trigger training
job = client.finetuning.train(
    memory_group="darwin_agent",
    lora_name="darwin_adapter",
)
print(job.status, job.message)

# Check status
status = client.finetuning.status(
    memory_group="darwin_agent",
    lora_name="darwin_adapter",
)
print(f"Ready: {status.lora_ready}")

# List all adapters
adapters = client.finetuning.list()
for a in adapters:
    print(f"{a.lora_name}: {a.status}")
```

### LoRA inference ([example](examples/finetuning.py))

```python
response = client.chat.completions.create(
    model="asymmetric/Qwen3-8B",
    messages=[{"role": "user", "content": "Tell me about Darwin's voyages"}],
    finetuning={"lora_name": "darwin_adapter"},
)
print(response.choices[0].message.content)
```

### Auto-training with memory ([example](examples/finetuning_with_memory.py))

```python
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "What did Darwin discover?"}],
    memory=[{"group": "darwin_agent", "goal": "Historical records about Darwin"}],
    finetuning={
        "lora_name": "darwin_adapter",
        "finetune_thresh": 3,
        "min_finetune_group": 5,
    },
)
```
