鱼C论坛

 找回密码
 立即注册
查看: 247|回复: 0

怎么把chatgpt回复的第一句套话去掉?

[复制链接]
发表于 2024-6-19 09:48:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
from openai import OpenAI

client = OpenAI(
    base_url = 'https://api.chre.tech/v1',
    api_key = "sk-loHrzSP2KEPOWUVFE5YjIxFZ2xv"      # 设置你的 API 密钥
)

def srtFileGPTTran(questionfile, srtZhFileNameAndPath):
    questionfile = "translate to Chinese:\n" + open(questionfile, "r", encoding="utf-8").read()
    print(questionfile)
    response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": questionfile}
    ]
    )
    reply = response.choices[0].message.content
    with open(srtZhFileNameAndPath, "w", encoding="utf-8") as file:
        file.write(reply)
    # return reply

srtEnFileNameMergeAndPath = '1.srt'
srtZhFileNameAndPath = '1zh11.srt'

srtFileGPTTran(srtEnFileNameMergeAndPath, srtZhFileNameAndPath)

1zh11.srt 的结果是:
Sure, here is the translation in Chinese:

1
00:00:00,084 --> 00:00:00,880
我很乐意来收拾。

2
00:00:01,154 --> 00:00:02,480
哦,你真好。

怎么让chatgpt 不说”Sure, here is the translation in Chinese:“ 这种话,只输出结果呢?

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-22 20:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表