Spaces:
Running
Running
Deploy OpenClaw PR API
Browse files
src/slop_farmer/app/pr_search.py
CHANGED
|
@@ -49,6 +49,7 @@ def format_pr_search_similar(result: Mapping[str, Any]) -> str:
|
|
| 49 |
"",
|
| 50 |
f"Active snapshot: {result['snapshot_id']}",
|
| 51 |
f"Lookup: {mode_used} via {source}",
|
|
|
|
| 52 |
"",
|
| 53 |
]
|
| 54 |
if not result["similar_prs"]:
|
|
@@ -102,6 +103,8 @@ def format_pr_search_clusters(result: Mapping[str, Any]) -> str:
|
|
| 102 |
f"PR #{result['pr']['pr_number']}: cluster context",
|
| 103 |
"",
|
| 104 |
f"Lookup: {mode_used} via {source}",
|
|
|
|
|
|
|
| 105 |
"",
|
| 106 |
"Assigned clusters:",
|
| 107 |
]
|
|
@@ -140,6 +143,7 @@ def format_pr_search_cluster(result: Mapping[str, Any]) -> str:
|
|
| 140 |
lines = [
|
| 141 |
f"Cluster {cluster['cluster_id']}",
|
| 142 |
f"Representative PR: #{cluster['representative_pr_number']}",
|
|
|
|
| 143 |
f"Average similarity: {cluster['average_similarity']:.2f}",
|
| 144 |
cluster["summary"],
|
| 145 |
"",
|
|
@@ -156,6 +160,7 @@ def format_pr_search_cluster_list(result: Mapping[str, Any]) -> str:
|
|
| 156 |
lines = [
|
| 157 |
f"Repo: {result['repo']}",
|
| 158 |
f"Active snapshot: {result['snapshot_id']}",
|
|
|
|
| 159 |
"",
|
| 160 |
"Clusters:",
|
| 161 |
]
|
|
@@ -165,7 +170,7 @@ def format_pr_search_cluster_list(result: Mapping[str, Any]) -> str:
|
|
| 165 |
return "\n".join(lines)
|
| 166 |
for index, cluster in enumerate(clusters, start=1):
|
| 167 |
lines.append(
|
| 168 |
-
f"{index}. {cluster['cluster_id']} representative=PR #{cluster['representative_pr_number']} "
|
| 169 |
f"size={cluster['cluster_size']} avg={cluster['average_similarity']:.2f}"
|
| 170 |
)
|
| 171 |
if cluster.get("representative_title"):
|
|
|
|
| 49 |
"",
|
| 50 |
f"Active snapshot: {result['snapshot_id']}",
|
| 51 |
f"Lookup: {mode_used} via {source}",
|
| 52 |
+
f"Matches: {result.get('similar_count', len(result['similar_prs']))}",
|
| 53 |
"",
|
| 54 |
]
|
| 55 |
if not result["similar_prs"]:
|
|
|
|
| 103 |
f"PR #{result['pr']['pr_number']}: cluster context",
|
| 104 |
"",
|
| 105 |
f"Lookup: {mode_used} via {source}",
|
| 106 |
+
f"Assigned: {result.get('assigned_cluster_count', len(result.get('assigned_clusters') or []))}",
|
| 107 |
+
f"Candidates: {result.get('candidate_cluster_count', len(result.get('candidate_clusters') or []))}",
|
| 108 |
"",
|
| 109 |
"Assigned clusters:",
|
| 110 |
]
|
|
|
|
| 143 |
lines = [
|
| 144 |
f"Cluster {cluster['cluster_id']}",
|
| 145 |
f"Representative PR: #{cluster['representative_pr_number']}",
|
| 146 |
+
f"Members: {result.get('member_count', len(result['members']))}",
|
| 147 |
f"Average similarity: {cluster['average_similarity']:.2f}",
|
| 148 |
cluster["summary"],
|
| 149 |
"",
|
|
|
|
| 160 |
lines = [
|
| 161 |
f"Repo: {result['repo']}",
|
| 162 |
f"Active snapshot: {result['snapshot_id']}",
|
| 163 |
+
f"Clusters returned: {result.get('cluster_count', len(result.get('clusters') or []))}",
|
| 164 |
"",
|
| 165 |
"Clusters:",
|
| 166 |
]
|
|
|
|
| 170 |
return "\n".join(lines)
|
| 171 |
for index, cluster in enumerate(clusters, start=1):
|
| 172 |
lines.append(
|
| 173 |
+
f"{cluster.get('rank', index)}. {cluster['cluster_id']} representative=PR #{cluster['representative_pr_number']} "
|
| 174 |
f"size={cluster['cluster_size']} avg={cluster['average_similarity']:.2f}"
|
| 175 |
)
|
| 176 |
if cluster.get("representative_title"):
|
src/slop_farmer/reports/pr_search_service.py
CHANGED
|
@@ -244,6 +244,7 @@ def get_pr_search_similar(
|
|
| 244 |
"run_id": run_id,
|
| 245 |
"pr": document,
|
| 246 |
"similar_prs": results,
|
|
|
|
| 247 |
}
|
| 248 |
finally:
|
| 249 |
connection.close()
|
|
@@ -283,6 +284,7 @@ def get_pr_search_candidate_clusters(
|
|
| 283 |
"run_id": run_id,
|
| 284 |
"pr": document,
|
| 285 |
"candidate_clusters": candidates,
|
|
|
|
| 286 |
}
|
| 287 |
finally:
|
| 288 |
connection.close()
|
|
@@ -333,6 +335,7 @@ def get_pr_search_similar_lookup(
|
|
| 333 |
"pr": live_result["probe_pr"],
|
| 334 |
"probe_source": live_result["probe_source"],
|
| 335 |
"similar_prs": live_result["similar_prs"],
|
|
|
|
| 336 |
}
|
| 337 |
|
| 338 |
|
|
@@ -387,6 +390,8 @@ def get_pr_search_clusters(
|
|
| 387 |
"probe_source": live_result["probe_source"],
|
| 388 |
"assigned_clusters": [],
|
| 389 |
"candidate_clusters": live_result["candidate_clusters"],
|
|
|
|
|
|
|
| 390 |
}
|
| 391 |
|
| 392 |
|
|
@@ -410,6 +415,7 @@ def get_pr_search_cluster(
|
|
| 410 |
"run_id": run_id,
|
| 411 |
"cluster": _cluster_summary(cluster),
|
| 412 |
"members": members,
|
|
|
|
| 413 |
}
|
| 414 |
finally:
|
| 415 |
connection.close()
|
|
@@ -443,11 +449,15 @@ def list_pr_search_clusters(
|
|
| 443 |
""",
|
| 444 |
[run_id, limit],
|
| 445 |
)
|
|
|
|
|
|
|
|
|
|
| 446 |
return {
|
| 447 |
"repo": active_run["repo"],
|
| 448 |
"snapshot_id": active_run["snapshot_id"],
|
| 449 |
"run_id": run_id,
|
| 450 |
-
"clusters":
|
|
|
|
| 451 |
}
|
| 452 |
finally:
|
| 453 |
connection.close()
|
|
@@ -770,6 +780,8 @@ def _get_pr_search_clusters_indexed(
|
|
| 770 |
"pr": document,
|
| 771 |
"assigned_clusters": assigned_clusters,
|
| 772 |
"candidate_clusters": candidates,
|
|
|
|
|
|
|
| 773 |
}
|
| 774 |
finally:
|
| 775 |
connection.close()
|
|
|
|
| 244 |
"run_id": run_id,
|
| 245 |
"pr": document,
|
| 246 |
"similar_prs": results,
|
| 247 |
+
"similar_count": len(results),
|
| 248 |
}
|
| 249 |
finally:
|
| 250 |
connection.close()
|
|
|
|
| 284 |
"run_id": run_id,
|
| 285 |
"pr": document,
|
| 286 |
"candidate_clusters": candidates,
|
| 287 |
+
"candidate_cluster_count": len(candidates),
|
| 288 |
}
|
| 289 |
finally:
|
| 290 |
connection.close()
|
|
|
|
| 335 |
"pr": live_result["probe_pr"],
|
| 336 |
"probe_source": live_result["probe_source"],
|
| 337 |
"similar_prs": live_result["similar_prs"],
|
| 338 |
+
"similar_count": len(live_result["similar_prs"]),
|
| 339 |
}
|
| 340 |
|
| 341 |
|
|
|
|
| 390 |
"probe_source": live_result["probe_source"],
|
| 391 |
"assigned_clusters": [],
|
| 392 |
"candidate_clusters": live_result["candidate_clusters"],
|
| 393 |
+
"assigned_cluster_count": 0,
|
| 394 |
+
"candidate_cluster_count": len(live_result["candidate_clusters"]),
|
| 395 |
}
|
| 396 |
|
| 397 |
|
|
|
|
| 415 |
"run_id": run_id,
|
| 416 |
"cluster": _cluster_summary(cluster),
|
| 417 |
"members": members,
|
| 418 |
+
"member_count": len(members),
|
| 419 |
}
|
| 420 |
finally:
|
| 421 |
connection.close()
|
|
|
|
| 449 |
""",
|
| 450 |
[run_id, limit],
|
| 451 |
)
|
| 452 |
+
clusters = []
|
| 453 |
+
for index, row in enumerate(rows, start=1):
|
| 454 |
+
clusters.append({"rank": index, **_cluster_summary(row)})
|
| 455 |
return {
|
| 456 |
"repo": active_run["repo"],
|
| 457 |
"snapshot_id": active_run["snapshot_id"],
|
| 458 |
"run_id": run_id,
|
| 459 |
+
"clusters": clusters,
|
| 460 |
+
"cluster_count": len(clusters),
|
| 461 |
}
|
| 462 |
finally:
|
| 463 |
connection.close()
|
|
|
|
| 780 |
"pr": document,
|
| 781 |
"assigned_clusters": assigned_clusters,
|
| 782 |
"candidate_clusters": candidates,
|
| 783 |
+
"assigned_cluster_count": len(assigned_clusters),
|
| 784 |
+
"candidate_cluster_count": len(candidates),
|
| 785 |
}
|
| 786 |
finally:
|
| 787 |
connection.close()
|