You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
852 B
32 lines
852 B
# coding=utf-8
|
|
|
|
import requests
|
|
import json
|
|
|
|
import urllib3
|
|
|
|
from Config import *
|
|
if __name__ == '__main__':
|
|
# 禁止警告
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
# Send request.
|
|
headers = {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer '+HW_API_KEY # 把yourApiKey替换成真实的API Key
|
|
}
|
|
data = {
|
|
"model": HW_MODEL_NAME,
|
|
"max_tokens": 20,
|
|
"messages": [
|
|
{"role": "system", "content": "You are a helpful assistant."},
|
|
{"role": "user", "content": "你好"}
|
|
],
|
|
"stream": False,
|
|
"temperature": 1.0
|
|
}
|
|
resp = requests.post(HW_API_URL, headers=headers, data=json.dumps(data), verify=False)
|
|
|
|
# Print result.
|
|
print(resp.status_code)
|
|
print(resp.text) |