Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2ef2c39
upd: clean over long or result files
csbobby Mar 17, 2026
5b64484
add: validation code generation
csbobby Mar 17, 2026
a09dfa8
add: validation code icl
csbobby Mar 17, 2026
bd3e158
add: prompt init
csbobby Mar 17, 2026
8cc6df3
add: validation decision
csbobby Mar 17, 2026
96abf0c
add: decomp jinja
csbobby Mar 17, 2026
c618622
refact: pipeline and primary stages
csbobby Mar 17, 2026
c865967
refact: module logging
csbobby Mar 17, 2026
a9af96c
fea: validation report
csbobby Mar 17, 2026
0373dcc
fea: validation report icl
csbobby Mar 17, 2026
31c162f
fea: cli script with config
csbobby Mar 17, 2026
32e4466
add: examples
csbobby Mar 17, 2026
f367f6b
add: examples
csbobby Mar 17, 2026
f81f41c
add: README doc
csbobby Mar 17, 2026
31a3b72
Merge branch 'generative-computing:main' into main
csbobby Mar 17, 2026
84dea26
Merge branch 'main' of https://github.com/csbobby/mellea_clean
csbobby Mar 17, 2026
97b09cc
pre-commit: add test attribute
csbobby Mar 17, 2026
e9f0686
upd: type annotations
csbobby Mar 18, 2026
e7ce9d5
fix: add constraint type annotation
csbobby Mar 18, 2026
cdfe9c3
upd: pre-commit format
csbobby Mar 18, 2026
2167a81
upd: pre-commit type annotations
csbobby Mar 18, 2026
ea6f740
upd: pre-commit format
csbobby Mar 18, 2026
70b8f68
add: m_decompose tests
csbobby Mar 18, 2026
53a5af2
add: constraint retry
csbobby Mar 18, 2026
d85867a
upd: constraint
csbobby Mar 18, 2026
ce7236a
upd: constraint
csbobby Mar 18, 2026
4040163
upd: same logmode
csbobby Mar 18, 2026
e7590f5
fix: a missed parse
csbobby Mar 18, 2026
001a8a9
pre-commit format
csbobby Mar 18, 2026
8e35a68
add: multi request support
csbobby Mar 18, 2026
910315c
clean
csbobby Mar 18, 2026
0df2cf8
fix: type clean
csbobby Mar 18, 2026
cca0b02
upd: input file arg
csbobby Mar 18, 2026
47a2e07
fea: constraint retry
csbobby Mar 19, 2026
16eb800
test
csbobby Mar 19, 2026
4f6ad9e
fix
csbobby Mar 19, 2026
2e476cc
fix
csbobby Mar 19, 2026
9ac0952
fix
csbobby Mar 19, 2026
9a0cd5b
clean: final result
csbobby Mar 19, 2026
468e685
add: decompose tests
csbobby Mar 19, 2026
3892862
add: decompose tests
csbobby Mar 19, 2026
65092c6
Merge pull request #1 from csbobby/debug
csbobby Mar 19, 2026
90ade35
clean: pre-commit format
csbobby Mar 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 141 additions & 142 deletions cli/decompose/decompose.py

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions cli/decompose/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import logging
import sys
from enum import StrEnum


class LogMode(StrEnum):
demo = "demo"
debug = "debug"


_CONFIGURED = False


def configure_logging(log_mode: LogMode = LogMode.demo) -> None:
global _CONFIGURED

level = logging.DEBUG if log_mode == LogMode.debug else logging.INFO

root_logger = logging.getLogger()

if not _CONFIGURED:
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(
logging.Formatter("[%(levelname)s] %(name)s | %(message)s")
)
root_logger.handlers.clear()
root_logger.addHandler(handler)
_CONFIGURED = True

root_logger.setLevel(level)

logging.getLogger("m_decompose").setLevel(level)
logging.getLogger("mellea").setLevel(level)


def get_logger(name: str) -> logging.Logger:
return logging.getLogger(name)


def log_section(logger: logging.Logger, title: str) -> None:
logger.info("")
logger.info("=" * 72)
logger.info(title)
logger.info("=" * 72)
15 changes: 15 additions & 0 deletions cli/decompose/m_decomp_result_v1.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import os
import textwrap

import mellea
{%- if "code" in identified_constraints | map(attribute="val_strategy") %}
from mellea.stdlib.requirement import req
{% for c in identified_constraints %}
{%- if c.val_fn %}
from validations.{{ c.val_fn_name }} import validate_input as {{ c.val_fn_name }}
{%- endif %}
{%- endfor %}
{%- endif %}

m = mellea.start_session()
{%- if user_inputs %}
Expand All @@ -30,7 +38,14 @@ except KeyError as e:
{%- if item.constraints %}
requirements=[
{%- for c in item.constraints %}
{%- if c.val_fn %}
req(
{{ c.constraint | tojson}},
validation_fn={{ c.val_fn_name }},
),
{%- else %}
{{ c.constraint | tojson}},
{%- endif %}
{%- endfor %}
],
{%- else %}
Expand Down
91 changes: 91 additions & 0 deletions cli/decompose/m_decomp_result_v2.py.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{% if user_inputs -%}
import os
{% endif -%}
import textwrap

import mellea
{%- if "code" in identified_constraints | map(attribute="val_strategy") %}
from mellea.stdlib.requirement import req
{% for c in identified_constraints %}
{%- if c.val_fn %}
from validations.{{ c.val_fn_name }} import validate_input as {{ c.val_fn_name }}
{%- endif %}
{%- endfor %}
{%- endif %}

m = mellea.start_session()
{%- if user_inputs %}


# User Input Variables
try:
{%- for var in user_inputs %}
{{ var | lower }} = os.environ["{{ var | upper }}"]
{%- endfor %}
except KeyError as e:
print(f"ERROR: One or more required environment variables are not set; {e}")
exit(1)
{%- endif %}
{%- for item in subtasks %}


{{ item.tag | lower }}_gnrl = textwrap.dedent(
R"""
{{ item.general_instructions | trim | indent(width=4, first=False) }}
""".strip()
)
{{ item.tag | lower }} = m.instruct(
{%- if not item.input_vars_required %}
{{ item.subtask[3:] | trim | tojson }},
{%- else %}
textwrap.dedent(
R"""
{{ item.subtask[3:] | trim }}

Here are the input variables and their content:
{%- for var in item.input_vars_required %}

- {{ var | upper }} = {{ "{{" }}{{ var | upper }}{{ "}}" }}
{%- endfor %}
""".strip()
),
{%- endif %}
{%- if item.constraints %}
requirements=[
{%- for c in item.constraints %}
{%- if c.val_fn %}
req(
{{ c.constraint | tojson}},
validation_fn={{ c.val_fn_name }},
),
{%- else %}
{{ c.constraint | tojson}},
{%- endif %}
{%- endfor %}
],
{%- else %}
requirements=None,
{%- endif %}
{%- if item.input_vars_required %}
user_variables={
{%- for var in item.input_vars_required %}
{{ var | upper | tojson }}: {{ var | lower }},
{%- endfor %}
},
{%- endif %}
grounding_context={
"GENERAL_INSTRUCTIONS": {{ item.tag | lower }}_gnrl,
{%- for var in item.depends_on %}
{{ var | upper | tojson }}: {{ var | lower }}.value,
{%- endfor %}
},
)
assert {{ item.tag | lower }}.value is not None, 'ERROR: task "{{ item.tag | lower }}" execution failed'
{%- if loop.last %}


final_answer = {{ item.tag | lower }}.value

print(final_answer)
{%- endif -%}
{%- endfor -%}
Loading
Loading