Skip to content

Commit 495631b

Browse files
abossardCopilot
andcommitted
Fix table truncation: show full content with word-wrap
Removed [:80] and [:100] truncation from actions.py and visualize.py. Table uses table-layout:fixed + word-break:break-word for wrapping. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5e4a2b5 commit 495631b

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

notebooks/dspy_tasks/actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ def _evaluate_examples(module, examples, metric_fn) -> list[dict]:
154154
input_kwargs = {k: ex[k] for k in ex.inputs().keys()}
155155
prediction = module(**input_kwargs)
156156
score = float(metric_fn(ex, prediction) or 0.0)
157-
input_str = " | ".join(f"{k}={str(v)[:80]}" for k, v in input_kwargs.items())
158-
expected_fields = {k: str(ex[k])[:80] for k in ex.keys() if k not in ex.inputs()}
159-
predicted_fields = {k: str(getattr(prediction, k, ""))[:80] for k in expected_fields}
157+
input_str = " | ".join(f"{k}={str(v)}" for k, v in input_kwargs.items())
158+
expected_fields = {k: str(ex[k]) for k in ex.keys() if k not in ex.inputs()}
159+
predicted_fields = {k: str(getattr(prediction, k, "")) for k in expected_fields}
160160
results.append({"input": input_str, "expected": str(expected_fields), "predicted": str(predicted_fields), "score": score})
161161
except Exception as e:
162162
results.append({"input": str({k: str(ex[k])[:50] for k in ex.inputs().keys()}), "expected": "N/A", "predicted": f"ERROR: {e}", "score": 0.0})

notebooks/dspy_tasks/visualize.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,29 +276,30 @@ def display_results_table(results: list[dict], max_rows: int = 20):
276276
score = r.get("score", 0)
277277
icon = "✅" if score >= 0.8 else "⚠️" if score >= 0.5 else "❌"
278278
bg = "#f0fdf0" if score >= 0.8 else "#fdf6f0" if score >= 0.5 else "#fdf0f0"
279-
input_text = str(r.get("input", ""))[:100]
280-
expected = str(r.get("expected", ""))[:80]
281-
predicted = str(r.get("predicted", ""))[:80]
279+
input_text = str(r.get("input", ""))
280+
expected = str(r.get("expected", ""))
281+
predicted = str(r.get("predicted", ""))
282+
td = 'style="padding:6px; border-bottom:1px solid #edebe9; font-size:0.85em; word-break:break-word"'
282283
rows += f'''
283284
<tr style="background:{bg}">
284-
<td style="padding:6px; border-bottom:1px solid #edebe9">{i+1}</td>
285-
<td style="padding:6px; border-bottom:1px solid #edebe9">{icon}</td>
286-
<td style="padding:6px; border-bottom:1px solid #edebe9; font-size:0.85em">{_escape_html(input_text)}</td>
287-
<td style="padding:6px; border-bottom:1px solid #edebe9; font-size:0.85em">{_escape_html(expected)}</td>
288-
<td style="padding:6px; border-bottom:1px solid #edebe9; font-size:0.85em">{_escape_html(predicted)}</td>
285+
<td {td}>{i+1}</td>
286+
<td {td}>{icon}</td>
287+
<td {td}>{_escape_html(input_text)}</td>
288+
<td {td}>{_escape_html(expected)}</td>
289+
<td {td}>{_escape_html(predicted)}</td>
289290
<td style="padding:6px; border-bottom:1px solid #edebe9; font-weight:bold">{score:.0%}</td>
290291
</tr>'''
291292

292293
html = f'''
293-
<table style="border-collapse:collapse; width:100%; margin:12px 0">
294+
<table style="border-collapse:collapse; width:100%; margin:12px 0; table-layout:fixed">
294295
<thead>
295296
<tr style="background:#f3f2f1">
296-
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886">#</th>
297-
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886"></th>
298-
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886">Input</th>
299-
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886">Expected</th>
300-
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886">Predicted</th>
301-
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886">Score</th>
297+
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886; width:30px">#</th>
298+
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886; width:30px"></th>
299+
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886; width:25%">Input</th>
300+
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886; width:25%">Expected</th>
301+
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886; width:25%">Predicted</th>
302+
<th style="padding:8px; text-align:left; border-bottom:2px solid #8a8886; width:50px">Score</th>
302303
</tr>
303304
</thead>
304305
<tbody>{rows}</tbody>

0 commit comments

Comments
 (0)