File size: 1,060 Bytes
88e3f4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest


def test_llm_infer_stream_not_loaded():
    from omniff.models.llm import LLMModel

    model = LLMModel(model_id="test")
    with pytest.raises(RuntimeError, match="not loaded"):
        list(model.infer_stream({"prompt": "hi"}))


def test_run_stream_is_generator():
    import types

    from omniff.runtime.config import OmniFFConfig, RouterConfig
    from omniff.runtime.engine import OmniFFRuntime

    config = OmniFFConfig(
        name="test",
        version="1.0",
        router=RouterConfig(router_type="keyword", path=""),
    )
    runtime = OmniFFRuntime(config)
    gen = runtime.run_stream(input="hello")
    assert isinstance(gen, types.GeneratorType)


def test_cli_has_stream_flag():
    import subprocess
    import sys

    result = subprocess.run(
        [sys.executable, "-m", "omniff.cli", "run", "--help"],
        capture_output=True,
        text=True,
        env={"PYTHONPATH": "python", "PATH": ""},
        cwd=str(__import__("pathlib").Path(__file__).parents[3]),
    )
    assert "--stream" in result.stdout