From 98a3e8ef78f673175a6890fd0ed8f39a6bd51b07 Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Thu, 18 Jan 2024 13:46:38 -0800 Subject: [PATCH] Add a llava example (#47) --- examples/quick_start/srt_example_llava.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/quick_start/srt_example_llava.py diff --git a/examples/quick_start/srt_example_llava.py b/examples/quick_start/srt_example_llava.py new file mode 100644 index 000000000..a781bede3 --- /dev/null +++ b/examples/quick_start/srt_example_llava.py @@ -0,0 +1,18 @@ +import sglang as sgl + + +@sgl.function +def image_qa(s, image_path, question): + s += sgl.user(sgl.image(image_path) + question) + s += sgl.assistant(sgl.gen("answer")) + + +runtime = sgl.Runtime(model_path="liuhaotian/llava-v1.5-7b", + tokenizer_path="llava-hf/llava-1.5-7b-hf") +sgl.set_default_backend(runtime) + + +state = image_qa.run(image_path="images/cat.jpeg", question="What is this?") +print(state["answer"]) + +runtime.shutdown()