chore: import upstream snapshot with attribution
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
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
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
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
from workflow import EvalInput, create_workflow
|
||||
|
||||
|
||||
async def test_single_row():
|
||||
"""Smoke test - requires Azure OpenAI credentials in .env"""
|
||||
wf = create_workflow()
|
||||
result = await wf.run(EvalInput(
|
||||
question="What is deep learning?",
|
||||
answer="Deep learning is a subset of machine learning.",
|
||||
context="Deep learning uses neural networks with many layers.",
|
||||
))
|
||||
score = result.get_outputs()[0]
|
||||
assert isinstance(score, float)
|
||||
print(f"PASS: test_single_row (score={score})")
|
||||
|
||||
|
||||
async def test_data_jsonl():
|
||||
"""Run eval on every row in data.jsonl"""
|
||||
data_path = Path(__file__).parent / "data.jsonl"
|
||||
rows = [json.loads(line) for line in data_path.read_text(encoding="utf-8").splitlines() if line.strip()]
|
||||
wf = create_workflow()
|
||||
for i, row in enumerate(rows):
|
||||
context = row["context"]
|
||||
if isinstance(context, list):
|
||||
context = "\n".join(context)
|
||||
result = await wf.run(EvalInput(
|
||||
question=row["question"],
|
||||
answer=row["answer"],
|
||||
context=context,
|
||||
))
|
||||
score = result.get_outputs()[0]
|
||||
assert isinstance(score, float), f"Row {i}: expected float, got {type(score)}"
|
||||
print(f" Row {i}: score={score}")
|
||||
print(f"PASS: test_data_jsonl ({len(rows)} rows)")
|
||||
|
||||
|
||||
async def main():
|
||||
await test_single_row()
|
||||
await test_data_jsonl()
|
||||
print("\nAll tests passed!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user