Skip to content

Commit 20ff1e1

Browse files
Trim retrieval context in backfill so full post stays visible
1 parent c176a8e commit 20ff1e1

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

scripts/backfill_opik_history.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,11 @@ def retrieval_context(course, question, answer, hide_doc_ids, _cache={}):
181181
both = [agent.index.search(question, num_results=10),
182182
agent.index.search(proposal, num_results=10)]
183183
results = keep_relevant(reciprocal_rank_fusion(both, weights=[1.0, 2.0], limit=5))
184+
# Keep match info only (id/question/section/score): full answer bodies bloat
185+
# the trace input ~5KB and bury the actual post in the UI. Full texts live
186+
# in the FAQ files; the question + score tell the retrieval story.
184187
keep = ("document_id", "question", "section_id", "score")
185-
trimmed = []
186-
for r in results:
187-
t = {k: r[k] for k in keep if k in r}
188-
t["answer"] = str(r.get("answer", ""))[:2000]
189-
trimmed.append(t)
190-
return trimmed
188+
return [{k: r[k] for k in keep if k in r} for r in results]
191189

192190

193191
def build_trace(issue, outcome):

0 commit comments

Comments
 (0)