Lightweight Python SDK for the Asymmetric API
Project description
asymmetric-py
Install
pip install asymmetric-py
Or install from source:
git clone https://github.com/asymmetric-dev/asymmetric-py.git
cd asymmetric-py
pip install .
Publishing
See PUBLISH.md.
Usage
from asymmetric import Asymmetric, GuardrailViolation
client = Asymmetric(api_key="sk_live_...")
Guardrails (example)
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)
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)
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)
violations = client.guardrails.list_violations()
for v in violations:
print(v.timestamp, v.guardrail_policy)
Finetuning (example)
# 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)
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)
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
Release history Release notifications | RSS feed
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.0.tar.gz
(7.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asymmetric_py-0.1.0.tar.gz.
File metadata
- Download URL: asymmetric_py-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd93a60025288d5c662ebd7d73ca4b7579b2d70e0f88154da6e7c97795153c39
|
|
| MD5 |
8461a9593d6874bb4dbc4ca4779d3032
|
|
| BLAKE2b-256 |
70d96b857de283d17911c3cec06699ca588a7dfe98225624f9142cc559c9034f
|
File details
Details for the file asymmetric_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: asymmetric_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
697e9547896165b9aa6668ec1fe2eb798d83262fe1d31eab6a8e4921dbe6bc6e
|
|
| MD5 |
a3fad372d8336af442d8e10464ebd32a
|
|
| BLAKE2b-256 |
5268622b0b703fab929d85c1427c5192db377867340268ceaa16c41191d76541
|