Skip to main content

SceneProgSyn

SceneProgSyn is an LLM-based module for generating Python-like code in any domain-specific language. This project depends on other SceneProg packages.


Installation

Install the package and its dependencies with:

pip install sceneprogsyn

Getting Started

Importing the package

from sceneprogsyn import SceneProgSyn, SceneProgDebugger

The package contains two key components:

  • SceneProgSyn: the main LLM-based coder
  • SceneProgDebugger: a powerful debugger that iterates through CodeRefine and TraceRefine steps to debug code

Working with an Example DSL

Language

SceneProgSyn shines when working with a custom DSL (Domain Specific Language), such as Blender Shader nodes, an Interior Design Inspired DSL (IDSDL, Gupta et al., 3D Vision 2026), CARLA, and more. For demonstration, we use an English Math DSL—a minimal, Python-like DSL that uses English words for numbers and operators to illustrate language design and interpretation.

This DSL supports:

  • Numbers written in words (e.g., one, two, three, …, twenty)
  • Arithmetic using English words (plus, minus, times, divided_by, power)
  • Variable assignments using Python-style syntax
  • Parentheses for precedence
  • Output via a print statement

Note: This DSL prioritizes clarity and simplicity to support educational demos and quick prototyping.

doc = """
**Numbers**  
Numbers are written using English words instead of digits.  
Examples: `zero`, `one`, `two`, `three`, `four`, `five`, … `twenty`  
(Unlike traditional numeric literals such as `0`, `1`, `2`.)

**Arithmetic Operations**  
Arithmetic operators are expressed as English words rather than symbols.

- `plus` — addition (instead of `+`)
- `minus` — subtraction (instead of `-`)
- `times` — multiplication (instead of `*`)
- `divided_by` — division (instead of `/`)
- `power` — exponentiation (instead of `**`)

**Variables**  
Variables follow Python-style naming rules and are assigned using `=`.

x = five plus three
"""

Execution Environment

Below is a simple execution environment for running the DSL. The __call__ method returns a status/output reflecting the execution state.

class Exec:
    def __init__(self):
        pass
    def __call__(self, code):
        try:
            return run_dsl(code)
        except Exception as e:
            return str(e)

Setting Up SceneProgSyn

First, initialize the SceneProgSyn object:

progsyn = SceneProgSyn(
    system_desc=f"""
You write Python programs in a custom DSL to solve user queries.
{doc}
""",
)

Next, configure the SceneProgDebugger. This involves writing a template that specifies the pieces required for writing programs in the DSL and provides prompts for the LLM-based debugging. To achieve this, define a SceneProgTemplate.

from sceneprogllm import SceneProgTemplate

template = SceneProgTemplate(
"""
<h>

</h>

<cr> 
You are an expert in Python scripting in a custom DSL. I want you to debug the following code by referring to the provided API doc.
$doc
An example of a valid output is:

a = two
b = three
c = a plus b
print c

</cr>

<tr>
You are an expert in Python scripting in a custom DSL. I want you to debug the following code by referring to the provided API doc.
$doc
You will be given a Python script that, along with the traceback, contains errors obtained by running the script.
Your task is to fix the code. An example of a valid output is:

a = two
b = three
c = a plus b
print c

</tr>

<f>

</f>
""",
)
  • <h> ... </h> is the program header, which typically contains imports and other setup crucial for execution but not strictly required to generate the full program.
  • <cr> ... </cr> and <tr> ... </tr> are the system prompts for CodeRefine and TraceRefine LLMs, respectively.
  • <f> ... </f> can be used to specify footer code (e.g., exporting results). Like the header, it is not required for program generation.
  • The SceneProgTemplate supports injecting runtime variables via $, which is useful for passing information to the debuggers.

Putting this together with SceneProgSyn:

debugger = SceneProgDebugger(Exec(), template, visualize=False)
progsyn.add_debugger(debugger)

A Simple DSL Program

Now, let's try writing a simple program in our DSL.

code = progsyn(
    "Write code to compute the function x^3 + 2*x^2 + x + 1",
    debugger_context={"doc": doc}
)
print("Generated Code:\n", code)

Example (generated DSL code):

# Define polynomial coefficients as variables
a = one
b = one
c = two
d = zero
e = one

# Evaluate polynomial f(x) = x^3 + 2x^2 + x + 1 using only expressions
x = three

x2 = x times x
x3 = x power three

term1 = x3
term2 = c times x2
term3 = b times x
term4 = a

result = term1 plus term2 plus term3 plus term4

print result

Notes:

  • The example demonstrates how the DSL uses English words to express numbers and operations.
  • The debugger template and the debugger workflow are designed to iteratively refine code to meet the DSL’s API and semantics.

Metadata

Release files for sceneprogsyn 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sceneprogsyn 0.1.1
File Size Uploaded Provenance
sceneprogsyn-0.1.1.tar.gz 5.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sceneprogsyn 0.1.1
File Interpreter ABI Platform
sceneprogsyn-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / sceneprogsyn-0.1.1.tar.gz

Download URL sceneprogsyn-0.1.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da88935148d86d36e7455b07cc15fedf2f59bbb040fb6cb74419192e4bf4bbc1
BLAKE2b-256 checksum
How to use checksums
3c82ef52c6c0ae9d810efe0f7299f033aa6c662b855fc953c88047e1b1bdf6ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / sceneprogsyn-0.1.1-py3-none-any.whl

Download URL sceneprogsyn-0.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f211e5027ce3e95b9137f5e2d5177ac25dc2f6091563ec1e42cbf70ddb636b09
BLAKE2b-256 checksum
How to use checksums
fbf257260f2596e008c3a8ba2225cf48083f747de5f555c960335ddb83050378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for sceneprogsyn 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page