Skip to main content

A modular agent-ready framework for exploring domain-specific languages (DSLs)

Project description

🧩 TinyDSL

License: Apache-2.0

TinyDSL is a modular, agent-ready framework for exploring and testing domain-specific languages (DSLs). It currently supports two DSLs:

  • 🎨 Gli — a graphics DSL for procedural image generation
  • 🗣️ Lexi — a text DSL for structured, expressive text generation and reasoning

Both are served via a unified FastAPI backend and are designed to be invoked by LLM agents or external REST clients.


⚙️ Get Started

Use uv:

uv venv
uv sync
python -m tinydsl.api.main

Open http://localhost:8008/docs.


🧠 Example Usage

Lexi (Text DSL)

set mood happy
say "Hello!"
repeat 2 { say "Have a wonderful day!" }

Lexi supports persistent memory:

remember name = "John Arthur"
recall name

Gli (Graphics DSL)

set color orange
repeat 10 {
  set size 3+$i
  draw circle x=cos($i*20)*$i*10 y=sin($i*20)*$i*10
}

Images save to /output as {id}_{name}_{YYYYMMDD_HHMMSS}.png (when id/name provided).


🚀 What’s New

  • Lark everywhere

    • lark_lexi_parser and lark_gli_parser now power both DSLs.
    • Deterministic, extensible grammars; clearer errors.
  • Pillow renderer by default (Gli)

    • Crisp, anti-aliased output via supersampling.
    • Matplotlib still available if you want it.
  • Smarter inline math

    • $i loop index, pi, e available.
    • Natural expressions like 10+$i*5 work.
    • calc(...) remains for explicit math.
  • AST endpoint (Lexi)

    • Get parse trees to inspect/visualize your programs.
  • Stable filenames

    • Artifacts saved as {id}_{name}_{timestamp}.png when id and/or name provided.

📚 API Overview

DSL Endpoint Method Purpose
Gli /api/gli/run POST Run graphics DSL code
Gli /api/gli/run_example/{id} GET Execute stored example
Lexi /api/lexi/run POST Execute Lexi DSL code
Lexi /api/lexi/task POST Run a predefined benchmark task
Lexi /api/lexi/eval POST Evaluate multiple outputs
Lexi /api/lexi/memory GET View persistent memory
Lexi /api/lexi/memory/clear POST Clear memory
Lexi /api/lexi/memory/set POST Set key-value in memory
Lexi /api/lexi/ast POST Get AST (raw dict / pretty / DOT)

🔧 Quick Calls

Run Lexi

curl -X POST http://localhost:8008/api/lexi/run \
  -H 'Content-Type: application/json' \
  -d '{"code":"set mood happy\nsay \"Hello!\""}'

Get Lexi AST

curl -X POST http://localhost:8008/api/lexi/ast \
  -H 'Content-Type: application/json' \
  -d '{"code":"say \"Hi\"","include_pretty":true,"include_dot":false}'

Run Gli (Pillow default)

curl -X POST http://localhost:8008/api/gli/run \
  -H 'Content-Type: application/json' \
  -d '{"id":"adhoc_001","name":"blue_circle","code":"set color blue\nset size 10\ndraw circle x=50 y=50","save":true}'

Run a stored Gli example

curl "http://localhost:8008/api/gli/run_example/003?save=true&engine=pillow"

🤖 Agent Integration

from tinydsl.agent_tools.tinydsl_tool import TinyDSLTool

tool = TinyDSLTool(base_url="http://localhost:8008/api")
print(tool.run_lexi('say "Hello there!"')["output"])
print(tool.run_lexi_task("005"))
print(tool.get_memory()); tool.clear_memory()

📦 Data & Files

  • Examples & grammars live under src/tinydsl/data/

    • gli_examples.json, gli_grammar.lark
    • lexi_tasks.json, lexi_grammar.lark
  • Outputs: ./output/ (images, lexi_memory.json)

You can override data paths with env vars: GLI_EXAMPLES_PATH, GLI_GRAMMAR_PATH, LEXI_TASKS_PATH, LEXI_GRAMMAR_PATH.


🧩 Extend

Add a new DSL by creating:

  • Parser + transformer (parser/lark_<dsl>.py)
  • Interpreter (<dsl>/<dsl>.py)
  • API router (api/routes_<dsl>.py)
  • Optional: examples + tasks JSON

Register it in api/main.py. TinyDSL’s modular design makes it easy to study continual learning, compositional reasoning, and symbolic generalization across DSLs.


🪪 License

Licensed under the Apache License, Version 2.0.
See LICENSE for details.


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

tinydsl-0.0.6.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

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

tinydsl-0.0.6-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file tinydsl-0.0.6.tar.gz.

File metadata

  • Download URL: tinydsl-0.0.6.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tinydsl-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f4d14c23e324aad3f0a79cb7cf995203316542a7dc2c54766d040ca731a83585
MD5 7b3c1638427681e574d991af608a4786
BLAKE2b-256 a5b269ea2c25cb79e2e72306ae6c345620aa4d61d4f774a722e1f98c4b35f9bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinydsl-0.0.6.tar.gz:

Publisher: publish.yml on deepsaia/tinydsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinydsl-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: tinydsl-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tinydsl-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 926724f6a37cf47649cf971f514bebfdd86721945b507d46802c6ffffb7d3d7b
MD5 6f0c64200d1e2ae404ce6df048ba52ac
BLAKE2b-256 ec44763bbe92082c5bd1580246e8c7a5412ec64b23531170b4418296d3ff4ba4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinydsl-0.0.6-py3-none-any.whl:

Publisher: publish.yml on deepsaia/tinydsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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