Skip to content

Commit

Permalink
🚀 Sort table data by percentage in descending order
Browse files Browse the repository at this point in the history
In bananalyzer/hooks.py, a sorting function has been added to sort the table_data array. This change is made to improve the clarity of the presentation by showcasing the data in terms of the percentage, starting from the highest.
  • Loading branch information
awtkns committed Nov 29, 2023
1 parent 19aad6d commit c21d7c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bananalyzer/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def print_field_data(
perfect = is_perfect and "✅" or "❌"
table_data.append([field, passed, failed, percentage, perfect])

table_data.sort(key=lambda row: row[3], reverse=True) # type: ignore

# Calculate the percentage for the total row
total_percentage = (
f"{total_passed / (total_passed + total_failed) * 100:.2f}%"
Expand Down
10 changes: 9 additions & 1 deletion bananalyzer/runner/null_agent_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from random import random
from typing import Any, cast

from playwright.async_api import Page

Expand All @@ -12,6 +13,8 @@ class NullAgentRunner(AgentRunner):
A test agent class that just returns an empty string
"""

RANDOM_FAILURE_RATE = 0 # You can change this to 0.5 to see random failures

async def run(
self,
page: Page,
Expand All @@ -29,4 +32,9 @@ async def run(
):
await page.goto(example.evals[0].expected)

return example.evals[0].expected
copy = cast(dict[str, Any], example.evals[0].expected).copy()
for key, value in copy.items():
if random() < self.RANDOM_FAILURE_RATE:
copy[key] = "random"

return copy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bananalyzer"
version = "0.6.4"
version = "0.6.5"

description = "Open source AI Agent evaluation framework for web tasks 🐒🍌"
authors = ["asim-shrestha <[email protected]>"]
Expand Down

0 comments on commit c21d7c5

Please sign in to comment.