Skip to content

Commit d2f8815

Browse files
authored
Merge branch 'generative-computing:main' into main
2 parents 7cc9966 + 4819407 commit d2f8815

File tree

14 files changed

+1030
-406
lines changed

14 files changed

+1030
-406
lines changed

docs/examples/generative_slots/inter_module_composition/summarizers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ def summarize_contract(contract_text: str) -> str:
1313

1414
@generative
1515
def summarize_short_story(story: str) -> str:
16-
"""Summarize a short story, with one paragraph on plot and one paragraph on braod themes."""
16+
"""Summarize a short story, with one paragraph on plot and one paragraph on broad themes."""

docs/examples/notebooks/compositionality_with_generative_slots.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"\n",
9696
"@generative\n",
9797
"def summarize_short_story(story: str) -> str:\n",
98-
" \"\"\"Summarize a short story, with one paragraph on plot and one paragraph on braod themes.\"\"\""
98+
" \"\"\"Summarize a short story, with one paragraph on plot and one paragraph on broad themes.\"\"\""
9999
]
100100
},
101101
{

docs/examples/notebooks/document_mobject.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
},
6161
"outputs": [],
6262
"source": [
63-
"!uv pip install mellea -q"
63+
"!uv pip install mellea[docling]"
6464
]
6565
},
6666
{

docs/examples/notebooks/georgia_tech.ipynb

Lines changed: 568 additions & 0 deletions
Large diffs are not rendered by default.

docs/examples/tutorial/compositionality_with_generative_slots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def summarize_contract(contract_text: str) -> str:
1414

1515
@generative
1616
def summarize_short_story(story: str) -> str:
17-
"""Summarize a short story, with one paragraph on plot and one paragraph on braod themes."""
17+
"""Summarize a short story, with one paragraph on plot and one paragraph on broad themes."""
1818

1919

2020
# The Decision Aides Library

mellea/stdlib/requirement.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import re
55
from collections.abc import Callable
6+
from copy import copy
67
from typing import Any, overload
78

89
from mellea.backends import (
@@ -97,6 +98,9 @@ def __init__(
9798
self.validation_fn = validation_fn
9899
self.check_only = check_only
99100

101+
# Used for validation. Do not manually populate.
102+
self._output: str | None = None
103+
100104
def validate(
101105
self,
102106
backend: Backend,
@@ -117,17 +121,18 @@ def validate(
117121
assert isinstance(last_output, ModelOutputThunk), (
118122
" Context has no appropriate last output"
119123
)
120-
self._output = last_output.value # type: ignore
124+
125+
# Create a copy of the requirement that holds the output
126+
# and its template gets populated with the output correctly.
127+
req_copy = copy(self)
128+
req_copy._output = last_output.value
121129
llm_as_a_judge_result = backend.generate_from_context(
122-
self,
130+
req_copy,
123131
ctx,
124132
format=format,
125133
model_options=model_options,
126134
generate_logs=generate_logs,
127135
)
128-
# This is crucial, because requirements can get reused;
129-
# this also means requirements are not thread-safe.
130-
self._output = None
131136
return ValidationResult(
132137
result=self.output_to_bool(llm_as_a_judge_result),
133138
reason=llm_as_a_judge_result.value,

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ ignore = [
138138
# "UP006", # List vs list, etc
139139
# "UP007", # Option and Union
140140
# "UP035", # `typing.Set` is deprecated, use `set` instead"
141+
"PD901", # Avoid using the generic variable name `df` for DataFrames
141142
]
142143

143144
[tool.ruff.lint.pydocstyle]
@@ -151,7 +152,7 @@ combine-as-imports = true
151152
split-on-trailing-comma = false
152153

153154
[tool.codespell]
154-
ignore-words-list = 'mellea,hashi,noo,Asai,asai'
155+
ignore-words-list = 'mellea,hashi,noo,Asai,asai,nd'
155156
check-filenames = true
156157
check-hidden = false
157158
regex = "(?<![a-z])[a-z'`]+|[A-Z][a-z'`]*|[a-z]+'[a-z]*|[a-z]+(?=[_-])|[a-z]+(?=[A-Z])|\\d+"

0 commit comments

Comments
 (0)