Skip to main content

Official Asymmetric (https://asymmetric.sh) SDK

Project description

asymmetric-py

Read the docs at https://asymmetric.sh/docs

Install

pip install asymmetric-py

Usage

from asymmetric import Asymmetric, GuardrailViolation

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

Guardrails

Basic completion

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

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

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

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

Memories

Log and use memories in a request

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"}
    ],
)
print(response.choices[0].message.content)

Finetuning

Trigger training and inspect status

job = client.finetuning.train(
    memory_group="darwin_agent",
    lora_name="darwin_adapter",
)
print(job.status, job.message)

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

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

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,
    },
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asymmetric_py-0.1.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asymmetric_py-0.1.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file asymmetric_py-0.1.1.tar.gz.

File metadata

  • Download URL: asymmetric_py-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for asymmetric_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 38bc81127645d2ae67c5ef379760366bbdf74a0d9a6aef08938a1784ed76ac6a
MD5 6d961fd156389ac62dd7be9aba66efa8
BLAKE2b-256 0a56a335df866432375f8eba999a6e772664b0ecb3dd848e398354371c172b03

See more details on using hashes here.

File details

Details for the file asymmetric_py-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for asymmetric_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 622b05eae75d15d9a91ddcb56ea22a451f41eca18b5b2d238495a91c0bc94bcf
MD5 39f85b8c64c8c2f3c070f5fd2dba3058
BLAKE2b-256 0d850bd9333ae2561a53a770077d59907dc97efa8f66659f6e5f5e733383fe60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page