Coverage for tests/test_verify.py: 94%

1 import pytest

2 import mall

3 import polars as pl

4 import pyarrow

5 import shutil

6 import os

7

8 if os._exists("_test_cache"):

9 shutil.rmtree("_test_cache", ignore_errors=True)

10

11

12 def 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 )

20

21

22 def 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 )