main
py 43 lines 1.38 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Set up this example by starting a vLLM OpenAI-compatible server.
4 Reasoning models can be used through the Responses API as seen here
5 https://platform.openai.com/docs/api-reference/responses
6 For example:
7 vllm serve Qwen/Qwen3-8B --reasoning-parser qwen3
8
9 """
10
11 from openai import OpenAI
12
13 input_messages = [{"role": "user", "content": "What model are you?"}]
14
15
16 def main():
17 base_url = "http://localhost:8000/v1"
18 client = OpenAI(base_url=base_url, api_key="empty")
19 model = "Qwen/Qwen3-8B" # get_first_model(client)
20 response = client.responses.create(
21 model=model,
22 input=input_messages,
23 )
24
25 for message in response.output:
26 if message.type == "reasoning":
27 # append reasoning message
28 input_messages.append(message)
29
30 response_2 = client.responses.create(
31 model=model,
32 input=input_messages,
33 )
34 print(response_2.output_text)
35 # I am Qwen, a large language model developed by Alibaba Cloud.
36 # I am designed to assist with a wide range of tasks, including
37 # answering questions, creating content, coding, and engaging in
38 # conversations. I can help with various topics and provide
39 # information or support in multiple languages. How can I assist you today?
40
41
42 if __name__ == "__main__":
43 main()