Coverage for tests/test_verify.py: 94%
18 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-15 15:57 -0500
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-15 15:57 -0500
1import pytest
2import mall
3import polars as pl
4import pyarrow
5import shutil
6import os
8if os._exists("_test_cache"):
9 shutil.rmtree("_test_cache", ignore_errors=True)
12def test_verify():
13 df = pl.DataFrame(dict(x=[1, 1, 0, 2]))
14 df.llm.use("test", "echo", _cache="_test_cache")
15 x = df.llm.verify("x", "this is my question")
16 assert (
17 x.select("verify").to_pandas().to_string()
18 == " verify\n0 1.0\n1 1.0\n2 0.0\n3 NaN"
19 )
22def test_verify_yn():
23 df = pl.DataFrame(dict(x=["y", "n", "y", "x"]))
24 df.llm.use("test", "echo", _cache="_test_cache")
25 x = df.llm.verify("x", "this is my question", ["y", "n"])
26 assert (
27 x.select("verify").to_pandas().to_string()
28 == " verify\n0 y\n1 n\n2 y\n3 None"
29 )