|
19 | 19 | from PIL import Image |
20 | 20 |
|
21 | 21 | import effectful.handlers.llm.evaluation as evaluation |
22 | | -from effectful.handlers.llm.synthesis import SynthesizedFunction |
23 | 22 | from effectful.ops.semantics import _simple_type |
24 | 23 | from effectful.ops.syntax import _CustomSingleDispatchCallable |
25 | 24 | from effectful.ops.types import Operation, Term |
@@ -284,6 +283,18 @@ def _format_callable_type(callable_type: type[Callable]) -> str: |
284 | 283 | return str(callable_type) |
285 | 284 |
|
286 | 285 |
|
| 286 | +class SynthesizedFunction(pydantic.BaseModel): |
| 287 | + """Structured output for function synthesis. |
| 288 | +
|
| 289 | + Pydantic model representing synthesized code with function name and module code. |
| 290 | + """ |
| 291 | + |
| 292 | + module_code: str = pydantic.Field( |
| 293 | + ..., |
| 294 | + description="Complete Python module code (no imports needed)", |
| 295 | + ) |
| 296 | + |
| 297 | + |
287 | 298 | def _create_typed_synthesized_function( |
288 | 299 | callable_type: type[Callable], |
289 | 300 | ) -> type[SynthesizedFunction]: |
@@ -477,12 +488,6 @@ def serialize( |
477 | 488 | def deserialize(self, serialized_value: str) -> SynthesizedFunction: |
478 | 489 | return SynthesizedFunction.model_validate_json(serialized_value) |
479 | 490 |
|
480 | | - @Operation.define |
481 | | - @classmethod |
482 | | - def encoding_instructions(cls) -> str | None: |
483 | | - """Instructions to be prefixed onto synthesis prompts to tune the encoding of the result.""" |
484 | | - return None |
485 | | - |
486 | 491 |
|
487 | 492 | @Encodable.define.register(object) |
488 | 493 | def _encodable_object[T, U]( |
|
0 commit comments