ASL (Agent Structure Language)
ASL (Agent Structure Language) — an internal DSL(Domain Specific Language) in Python for building agents based on bridgic-core. It provides a declarative, intuitive syntax for defining complex workflow graphs and concurrent automata, making it easier to build and maintain agent-based applications.
Features
- Declarative Syntax: Define workflows using intuitive Python syntax with context managers
- Rich Operators: Use
+,~,>>, and&operators to express complex dependencies - Fragment Support: Group workers into reusable logical fragments
- Nested Graphs: Support for hierarchical graph structures
- Component Reuse: Reuse existing automata as sub-graphs
- Dynamic Workers: Lambda-based dynamic worker generation for concurrent automata
Installation
pip install bridgic-asl
Quick Start
Basic Example
from bridgic.asl import ASLAutoma, graph
def add_one(x: int):
return x + 1
def add_two(x: int):
return x + 2
class MyGraph(ASLAutoma):
with graph as g:
a = add_one
b = add_two
+a >> ~b # a is the start worker, b depends on a and is the output
# Run the graph
graph = MyGraph()
result = await graph.arun(x=1) # result: 3 (1+1+2)
Operators Explained
+marks a worker as a start worker (entry point)~marks a worker as an output worker (exit point)>>defines a dependency (left must complete before right executes)&groups multiple workers together
Fragment Example
from bridgic.asl import ASLAutoma, graph
class MyGraph(ASLAutoma):
with graph as g:
a = worker1
b = worker11
c = worker12
d = worker5
e = worker6
# Create fragments
fragment_1 = +(a & b & c) # Fragment with start workers
fragment_2 = (d & e) # Regular fragment
# Chain fragments together
fragment_1 >> fragment_2 >> ~merge
Nested Graphs
class MyGraph(ASLAutoma):
with graph as g:
a = SubGraph2()
b = worker2
+a >> b
# Nested graph
with graph as sub_graph:
x = worker1
y = worker2
+x >> ~y
Configuration and Parameter Injection
from bridgic.asl import ASLAutoma, graph, Settings, Data
from bridgic.core.automa.args import ArgsMappingRule, From
class MyGraph(ASLAutoma):
with graph as g:
a = worker1
b = worker2 *Settings(args_mapping_rule=ArgsMappingRule.AS_IS)
c = merge *Data(y=From("a")) # Inject parameter from worker 'a'
+a >> b >> ~c
Concurrent Automa with Dynamic Workers
from bridgic.asl import ASLAutoma, concurrent, ASLField, Settings
from bridgic.core.automa.args import ResultDispatchingRule
class MyConcurrent(ASLAutoma):
with concurrent(subtasks=ASLField(list, dispatching_rule=ResultDispatchingRule.IN_ORDER)) as sub_concurrent:
dynamic_logic = lambda subtasks: (
tasks_done *Settings(key=f"tasks_done_{i}")
for i, subtask in enumerate(subtasks)
)
Core Concepts
ASLAutoma
The main class that extends GraphAutoma from bridgic-core. Define your agent by inheriting from ASLAutoma and using the graph or concurrent context managers.
Graph vs Concurrent
graph: Creates aGraphAutomafor workflow executionconcurrent: Creates aConcurrentAutomafor parallel task execution
Settings
Configure worker behavior:
worker *Settings(
key="custom_key",
args_mapping_rule=ArgsMappingRule.AS_IS,
result_dispatching_rule=ResultDispatchingRule.IN_ORDER
)
Data
Inject default parameter values and modify function signatures:
worker *Data(param1=value1, param2=From("other_worker"))
Requirements
- Python >= 3.9
- bridgic-core >= 0.1.5.dev1
Metadata
Release files for bridgic-asl 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bridgic_asl-0.1.3.tar.gz | 19.4 kB | Without provenance | Details for bridgic_asl-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bridgic_asl-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for bridgic_asl-0.1.3-py3-none-any.whl |
Total release size: 40.9 kB
Release files / bridgic_asl-0.1.3.tar.gz
| Download URL | bridgic_asl-0.1.3.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
acc067e1c0e0bac716b43ed1971711f0b46bdb09390b39e6e98337bc52a6d200
|
|
BLAKE2b-256 checksum How to use checksums |
bed219fd89b6cbc89efa14af4016a69c64edef0d3016e7f2c2da523e3a78bdad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / bridgic_asl-0.1.3-py3-none-any.whl
| Download URL | bridgic_asl-0.1.3-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce96db09336d06191f3326e8e545376538179c4622a8dcb5d8bcd687727132af
|
|
BLAKE2b-256 checksum How to use checksums |
ec399871a2b4da92cfbb297252dc7301f132bab7d4de71dafae849b7899b7331
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for bridgic-asl 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.