Xinference 的 qwen2模型调用代码
from openai import OpenAI
# 注意服务端端口,因为是本地,所以不需要api_key
client = OpenAI(base_url="http://192.168.254.206:9997/v1",
api_key="EMPTY")
completion = client.chat.completions.create(
model="qwen2-instruct",
messages= [
{"role": "system", "content": "你是一个智能助理,你的回答总是容易理解的、正确的、有用的和内容非常精简."},{"role": "user", "content": "你好"}
],
temperature=0.9,
stream=False,
)
print(completion)