Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Fix multiline init regex parsing

Michael Ryan9687c3c3b11d
diff --git a/dspy/propose/grounded_proposer.py b/dspy/propose/grounded_proposer.py
index 130c20ad8..2f50b8a53 100644
--- a/dspy/propose/grounded_proposer.py
+++ b/dspy/propose/grounded_proposer.py
@@ -192,7 +192,7 @@ class GenerateModuleInstruction(dspy.Module):
print(f"PROGRAM DESCRIPTION: {program_description}")
# Identify all modules
- init_pattern = r"def __init__\(.*?\):([\s\S]*?)(?=^\s*def|\Z)"
+ init_pattern = r"def __init__\([\s\S]*?\):([\s\S]*?)(?=^\s*def|\Z)"
init_content_match = re.search(init_pattern, self.program_code_string)
init_content = init_content_match.group(0)
pattern = r"^(.*dspy\.(ChainOfThought|Predict).*)$" # TODO: make it so that this extends out to any dspy Module