|
3 | 3 | from pathlib import Path |
4 | 4 |
|
5 | 5 | import pandas as pd |
| 6 | +from pydantic_ai import Agent |
| 7 | +from tenacity import retry, stop_after_attempt, wait_exponential |
| 8 | + |
| 9 | +agent = Agent( |
| 10 | + "google-gla:gemini-2.5-pro", |
| 11 | + system_prompt=( |
| 12 | + "Directly generate a markdown summary of the provided benchmark results. " |
| 13 | + "Do not include any conversational filler or introductory sentences. " |
| 14 | + "Your response should begin immediately with the summary content, " |
| 15 | + "structured with markdown sub-headings (e.g., '#### Summary', '##### Insert Performance', '#### Search Performance'). " |
| 16 | + "The summary should analyze insert and search performance, " |
| 17 | + "compare the different implementations, and include speedup metrics." |
| 18 | + ), |
| 19 | +) |
| 20 | + |
| 21 | + |
| 22 | +@retry(wait=wait_exponential(multiplier=1, min=4, max=10), stop=stop_after_attempt(3)) |
| 23 | +def generate_summary(agent: Agent, benchmark_markdown_output: str) -> str: |
| 24 | + results = agent.run_sync(benchmark_markdown_output) |
| 25 | + return results.output |
6 | 26 |
|
7 | 27 |
|
8 | 28 | def compare_benchmarks(): |
@@ -62,6 +82,10 @@ def compare_benchmarks(): |
62 | 82 | markdown_output = group.to_markdown(index=False) |
63 | 83 | if markdown_output: |
64 | 84 | f.write(markdown_output) |
| 85 | + # Generate a comparision summary section via LLM which includes the speedup gains and/os losses |
| 86 | + f.write("\n\n#### AI Summary\n") |
| 87 | + summary = generate_summary(agent, markdown_output) |
| 88 | + f.write(summary) |
65 | 89 | f.write("\n\n") |
66 | 90 |
|
67 | 91 | print("--- Finished benchmark comparison successfully ---") |
|
0 commit comments