test_vertexai_backend.py 1.52 KB
Newer Older
shiyi.c_98's avatar
shiyi.c_98 committed
1
2
import unittest

Liangsheng Yin's avatar
Liangsheng Yin committed
3
from sglang import VertexAI, set_default_backend
shiyi.c_98's avatar
shiyi.c_98 committed
4
5
6
7
8
9
10
11
12
13
14
from sglang.test.test_programs import (
    test_expert_answer,
    test_few_shot_qa,
    test_image_qa,
    test_mt_bench,
    test_parallel_decoding,
    test_parallel_encoding,
    test_stream,
)


15
class TestVertexAIBackend(unittest.TestCase):
shiyi.c_98's avatar
shiyi.c_98 committed
16
17
18
19
    backend = None
    chat_backend = None
    chat_vision_backend = None

20
21
22
23
24
    @classmethod
    def setUpClass(cls):
        cls.backend = VertexAI("gemini-pro")
        cls.chat_backend = VertexAI("gemini-pro")
        cls.chat_vision_backend = VertexAI("gemini-pro-vision")
shiyi.c_98's avatar
shiyi.c_98 committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

    def test_few_shot_qa(self):
        set_default_backend(self.backend)
        test_few_shot_qa()

    def test_mt_bench(self):
        set_default_backend(self.chat_backend)
        test_mt_bench()

    def test_expert_answer(self):
        set_default_backend(self.backend)
        test_expert_answer()

    def test_parallel_decoding(self):
        set_default_backend(self.backend)
        test_parallel_decoding()

    def test_parallel_encoding(self):
        set_default_backend(self.backend)
        test_parallel_encoding()

    def test_image_qa(self):
        set_default_backend(self.chat_vision_backend)
        test_image_qa()

    def test_stream(self):
        set_default_backend(self.backend)
        test_stream()


if __name__ == "__main__":
    unittest.main(warnings="ignore")

    # from sglang.global_config import global_config

    # global_config.verbosity = 2
61
    # t = TestVertexAIBackend()
62
    # t.setUpClass()
shiyi.c_98's avatar
shiyi.c_98 committed
63
    # t.test_stream()