NOTavaliable commited on
Commit
888f9aa
·
verified ·
1 Parent(s): 4be5a03

Upload code/test.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. code/test.py +24 -0
code/test.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openai import OpenAI
2
+
3
+ client = OpenAI(
4
+ base_url="http://127.0.0.1:8000/v1",
5
+ api_key="EMPTY", # vLLM 默认通常不校验 API Key
6
+ )
7
+
8
+ response = client.chat.completions.create(
9
+ model="qwen2.5-32b-instruct", # 必须与 --served-model-name 一致
10
+ messages=[
11
+ {
12
+ "role": "system",
13
+ "content": "You are a helpful assistant.",
14
+ },
15
+ {
16
+ "role": "user",
17
+ "content": "简单介绍一下检索增强生成(RAG)。",
18
+ },
19
+ ],
20
+ temperature=0,
21
+ max_tokens=512,
22
+ )
23
+
24
+ print(response.choices[0].message.content)