59 lines
2.3 KiB
Python
59 lines
2.3 KiB
Python
"""Live smoke tests against the real provider configured in the examples'
|
|
pipewright.live.yaml (DeepSeek via Morph). Run with `pytest --live`; kept small and
|
|
paced (the key's per-minute limits are shared)."""
|
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
|
|
from pipewright import ops
|
|
from pipewright.models.base import ModelClient
|
|
from pipewright.project import Project
|
|
|
|
pytestmark = pytest.mark.live
|
|
|
|
|
|
def test_live_issue_triage(example):
|
|
d = example("issue_triage")
|
|
s = ops.run_graph(d / "graph.py", project=d / "pipewright.live.yaml", limit=4)
|
|
assert s["status"] == "completed", s["errors"]
|
|
items = ops.items(d / "graph.py", "classify", project=d / "pipewright.live.yaml", n=10)["items"]
|
|
assert len(items) == 4
|
|
for it in items:
|
|
assert it["labels"]["category"] in ("bug", "feature", "question", "docs")
|
|
assert 0 <= it["labels"]["severity"] <= 3
|
|
by_key = {it["key"]: it["labels"] for it in items}
|
|
assert by_key["gh-101"]["category"] == "bug" # a crash with a traceback
|
|
assert by_key["gh-102"]["category"] == "feature" # dark mode
|
|
usage = s["usage"][0]
|
|
assert usage["calls"] >= 4 and usage["input_tokens"] > 0 and usage["output_tokens"] > 0
|
|
|
|
|
|
def test_live_streaming_path(example):
|
|
d = example("issue_triage")
|
|
proj = Project.load(d / "pipewright.live.yaml")
|
|
proj.config.providers["morph"]["stream"] = True
|
|
alias = proj.config.models["labeler"].model_copy(update={"cache": False})
|
|
client = ModelClient("labeler", alias, proj.provider("morph"))
|
|
|
|
async def main():
|
|
try:
|
|
return await client.chat([{"role": "user", "content": "Reply with exactly the word: pong"}], max_tokens=200)
|
|
finally:
|
|
await proj.aclose()
|
|
|
|
res = asyncio.run(main())
|
|
assert "pong" in res.content.lower() and res.usage.output_tokens > 0
|
|
|
|
|
|
def test_live_coding_agent(example):
|
|
d = example("coding_tasks")
|
|
s = ops.run_graph(d / "graph.py", project=d / "pipewright.live.yaml", limit=2)
|
|
assert s["status"] in ("completed", "completed_with_errors"), s["errors"]
|
|
nodes = s["funnel"]["nodes"]
|
|
assert nodes["synth"]["out"]["out"] == 2
|
|
# every validated task got 2 rollouts that were graded (no provider failures recorded as results)
|
|
n_valid = nodes["valid"]["out"].get("out", 0)
|
|
assert nodes["probe"]["out"].get("out", 0) == 2 * n_valid
|
|
assert sum(nodes["bucket"]["out"].values()) == n_valid
|