e768098d0e
Flake8 Lint / flake8 (push) Waiting to run
Spell check CI / Spell_Check (push) Waiting to run
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import argparse
|
|
import asyncio
|
|
import json
|
|
from pathlib import Path
|
|
from aggregation import aggregate
|
|
from eval_runner import EvalRunner
|
|
from workflow import EvalInput, create_workflow
|
|
|
|
DEFAULT_DATA = Path(__file__).parent / "data.jsonl"
|
|
|
|
|
|
def load_dataset(path: Path) -> list[EvalInput]:
|
|
rows = []
|
|
with open(path, encoding="utf-8") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line:
|
|
obj = json.loads(line)
|
|
rows.append(EvalInput(document=obj["document"], summary=obj["summary"]))
|
|
return rows
|
|
|
|
|
|
async def main(data_path: Path, concurrency: int):
|
|
dataset = load_dataset(data_path)
|
|
print(f"Loaded {len(dataset)} rows from {data_path}")
|
|
|
|
runner = EvalRunner(
|
|
workflow_factory=create_workflow,
|
|
aggregate_fn=aggregate,
|
|
concurrency=concurrency,
|
|
)
|
|
result = await runner.run(dataset)
|
|
|
|
print("\n--- Metrics ---")
|
|
for key, value in result.metrics.items():
|
|
print(f" {key}: {value}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--data", type=Path, default=DEFAULT_DATA)
|
|
parser.add_argument("--concurrency", type=int, default=5)
|
|
args = parser.parse_args()
|
|
asyncio.run(main(args.data, args.concurrency))
|