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.

29 lines
1012 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from openai import OpenAI
from pathlib import Path
# https://help.aliyun.com/zh/model-studio/developer-reference/deepseek?spm=a2c4g.11186623.0.0.274b1d1c4GY0Zd
API_KEY = "sk-01d13a39e09844038322108ecdbd1bbc"
client = OpenAI(
api_key=API_KEY,
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
# 读取文本文件内容
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)
completion = client.chat.completions.create(
model="deepseek-v3", # 此处以 deepseek-r1 为例,可按需更换模型名称。
messages=[
{'role': 'user', 'content': "帮我梳理:这节课分了几个部分,每部分的名称和开始的时间是多少:"+content}
]
)
# 通过content字段打印最终答案
print(completion.choices[0].message.content)