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.
|
|
|
|
|
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
url = "https://infer-modelarts-cn-southwest-2.modelarts-infer.com/v1/infers/fd53915b-8935-48fe-be70-449d76c0fc87/v1/chat/completions"
|
|
|
|
|
API_KEY = 'WooxVHbV5-5nEuFJtMxaktMVo07Ic3iKbq_y4wHsjRvmSgbCehcGW62RmWLPvi_WoLzwpoNbCGmrksjSAlykGg'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 读取文本文件内容
|
|
|
|
|
file_path = Path(r"D:\dsWork\QingLong\音频文本.txt")
|
|
|
|
|
|
|
|
|
|
if file_path.exists():
|
|
|
|
|
# 自动处理文件编码(默认utf-8),读取内容
|
|
|
|
|
content = file_path.read_text(encoding='utf-8')
|
|
|
|
|
else:
|
|
|
|
|
print(f"文件 {file_path} 不存在")
|
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
|
|
# Send request.
|
|
|
|
|
headers = {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
'Authorization': 'Bearer '+API_KEY
|
|
|
|
|
}
|
|
|
|
|
data = {
|
|
|
|
|
"model": "DeepSeek-V3",
|
|
|
|
|
"max_tokens": 20,
|
|
|
|
|
"messages": [
|
|
|
|
|
{"role": "system", "content": "You are a helpful assistant."},
|
|
|
|
|
{"role": "user", "content": "整理下面的JSON文件内容,输出这段话共分几部分,都是哪个时间开始的:"+content}
|
|
|
|
|
],
|
|
|
|
|
# 是否开启流式推理, 默认为False, 表示不开启流式推理
|
|
|
|
|
"stream": False,
|
|
|
|
|
# 在流式输出时是否展示使用的token数目。只有当stream为True时改参数才会生效。
|
|
|
|
|
# "stream_options": { "include_usage": True },
|
|
|
|
|
# 控制采样随机性的浮点数,值较低时模型更具确定性,值较高时模型更具创造性。"0"表示贪婪取样。默认为1.0。
|
|
|
|
|
"temperature": 1.0
|
|
|
|
|
}
|
|
|
|
|
resp = requests.post(url, headers=headers, data=json.dumps(data), verify=False)
|
|
|
|
|
|
|
|
|
|
# Print result.
|
|
|
|
|
print(resp.status_code)
|
|
|
|
|
print(resp.text)
|