DSPy: The framework for programming—not prompting—language models
Python
fix: allow field headers and content on same line in parser (#7955)
Francesco Laiti431148399ced
diff --git a/dspy/adapters/chat_adapter.py b/dspy/adapters/chat_adapter.pyindex 71b56ccc3..beb74a28a 100644--- a/dspy/adapters/chat_adapter.py+++ b/dspy/adapters/chat_adapter.py@@ -86,7 +86,10 @@ class ChatAdapter(Adapter):for line in completion.splitlines():match = field_header_pattern.match(line.strip())if match:- sections.append((match.group(1), []))+ # If the header pattern is found, split the rest of the line as content+ header = match.group(1)+ remaining_content = line[match.end():].strip()+ sections.append((header, [remaining_content] if remaining_content else []))else:sections[-1][1].append(line)