mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
Update test_openai.py
This commit is contained in:
@@ -21,7 +21,7 @@ service_http_port = "9908" # 服务配置的
|
||||
|
||||
client = openai.Client(base_url=f"http://{ip}:{service_http_port}/v1", api_key="EMPTY_API_KEY")
|
||||
|
||||
# 非流式返回
|
||||
# 非流式返回, completion接口不会使用chat template对输入进行处理
|
||||
response = client.completions.create(
|
||||
model="default",
|
||||
prompt="There are 50 kinds of fruits, include apple, banana, pineapple",
|
||||
@@ -33,7 +33,7 @@ response = client.completions.create(
|
||||
print(response)
|
||||
print("\n")
|
||||
|
||||
# 流式返回
|
||||
# 流式返回, completion接口不会使用chat template对输入进行处理
|
||||
response = client.completions.create(
|
||||
model="default",
|
||||
prompt="Hello, how are you?",
|
||||
@@ -46,12 +46,12 @@ for chunk in response:
|
||||
print("\n")
|
||||
|
||||
# Chat completion
|
||||
# 非流式返回
|
||||
# 非流式返回, 会基于chat template对输入进行拼接处理
|
||||
response = client.chat.completions.create(
|
||||
model="default",
|
||||
messages=[
|
||||
{"role": "user", "content": "Hello, who are you"},
|
||||
{"role": "system", "content": "I'm a helpful AI assistant."},
|
||||
{"role": "user", "content": "Hello, who are you"},
|
||||
{"role": "user", "content": "List 3 countries and their capitals."},
|
||||
],
|
||||
temperature=1,
|
||||
@@ -63,7 +63,7 @@ print(response)
|
||||
print("\n")
|
||||
|
||||
|
||||
# # 流式返回
|
||||
# # 流式返回, 会基于chat template对输入进行拼接处理
|
||||
response = client.chat.completions.create(
|
||||
model="default",
|
||||
messages=[
|
||||
|
Reference in New Issue
Block a user