1028.py
All checks were successful
test / job_1 (push) Successful in 43s

This commit is contained in:
298977887 2024-10-28 22:02:29 +08:00
parent ef1edad035
commit 05594b5e95

View File

@ -2,6 +2,7 @@ import requests
from datetime import datetime, timezone, timedelta
import logging
import json
import re
# 配置日志
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@ -43,24 +44,31 @@ else:
if commit_date == latest_commit_date:
commit_message = commit['commit']['message']
all_commits_text += commit_message + "\n" # 将每个提交信息添加到字符串中
# 移除包含 "Signed-off-by" 的行
commit_message = re.sub(r'^Signed-off-by:.*$', '', commit_message, flags=re.MULTILINE)
all_commits_text += commit_message.strip() + "\n" # 清除多余的空格
logging.info(f"找到匹配的提交日期: {commit_date},提交信息: {commit_message}")
# 使用 llama3.2 模型翻译
logging.info("开始调用 llama3.2 模型进行翻译")
translation_api_url = "https://ollama.aoun.ltd/api/generate"
headers = {"Content-Type": "application/json"}
# 设置翻译的 prompt强调技术文档风格
prompt = f"""
你是一位熟悉技术文档硬件描述和设备树配置的专业翻译员请准确且简洁地将以下内容从英文翻译成简体中文
要求
1. 遵循技术术语的准确性不意译不简化
2. 逐条翻译每一条更新内容保持原始信息完整分段显示
3. 使用专业简洁的风格确保每条更新信息单独呈现
2. 忽略任何包含 Signed-off-by 的内容
3. 逐条翻译每一条更新内容保持原始信息完整分段显示
4. 使用专业简洁的风格确保每条更新信息单独呈现
以下是需要翻译的内容
{all_commits_text}
"""
payload = {
"model": "llama3.2",
"prompt": prompt,