Skip to content

Commit 1457247

Browse files
authored
Fix structured cot (#368)
I updated generator.py:313-324 to automatically increase max_tokens to 4000 for conversation types that require complex structured outputs: cot_structured cot_hybrid agent_cot_hybrid agent_cot_multi_turn xlam_multi_turn Resolves: #359
1 parent ca29813 commit 1457247

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

deepfabric/format_command.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""Format command implementation for DeepFabric CLI."""
2-
31
import click
42
import yaml
53

deepfabric/generator.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,17 @@ async def _generate_structured_samples_async(
310310

311311
async def _generate(prompt: str) -> tuple[bool, dict | Exception]:
312312
try:
313-
# Use higher of max_tokens, 4000 tokens for multi-turn conversations
313+
# Use higher max_tokens for complex conversation types to prevent truncation
314314
max_tokens = self.config.max_tokens
315-
if self.config.conversation_type == "xlam_multi_turn":
315+
316+
# Structured CoT types need more tokens for reasoning traces + messages
317+
if self.config.conversation_type in {
318+
"cot_structured",
319+
"cot_hybrid",
320+
"agent_cot_hybrid",
321+
"agent_cot_multi_turn",
322+
"xlam_multi_turn",
323+
}:
316324
max_tokens = max(max_tokens, 4000)
317325

318326
conversation = await self.llm_client.generate_async(

deepfabric/metrics.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
"""
2-
Simple analytics for DeepFabric using PostHog.
3-
4-
Provides a single trace() function for anonymous usage analytics.
5-
All analytics can be disabled by setting ANONYMIZED_TELEMETRY=False.
6-
"""
7-
81
import contextlib
92
import os
103

0 commit comments

Comments
 (0)