Compare commits
2 Commits
4deaa35c76
...
aa1e929f63
| Author | SHA1 | Date | |
|---|---|---|---|
| aa1e929f63 | |||
| ef43ad213b |
@ -39,17 +39,29 @@ def load_users():
|
||||
return {}
|
||||
|
||||
|
||||
# 转换为字典格式 {username: {'password': password, 'api_key': api_key, 'config_file': config_file}}
|
||||
# 转换为字典格式 {username: {'password': password, 'api_key': api_key, 'config_file': config_file, 'model': model}}
|
||||
users = {}
|
||||
for _, row in df.iterrows():
|
||||
# 跳过空行或列数不足的行
|
||||
if len(row) < 2 or pd.isna(row.iloc[0]) or pd.isna(row.iloc[1]):
|
||||
continue
|
||||
|
||||
username = str(row.iloc[0]).strip() # 第一列:用户名
|
||||
password = str(row.iloc[1]).strip() # 第二列:密码
|
||||
api_key = str(row.iloc[2]).strip() if len(row) > 2 else 'OPENAI_API_KEY' # 第三列:API_KEY
|
||||
config_file = str(row.iloc[3]).strip() if len(row) > 3 else None # 第四列:配置文件
|
||||
|
||||
# 跳过空用户名或密码
|
||||
if not username or not password or username == 'nan' or password == 'nan':
|
||||
continue
|
||||
|
||||
api_key = str(row.iloc[2]).strip() if len(row) > 2 and not pd.isna(row.iloc[2]) else 'OPENAI_API_KEY' # 第三列:API_KEY
|
||||
config_file = str(row.iloc[3]).strip() if len(row) > 3 and not pd.isna(row.iloc[3]) else None # 第四列:配置文件
|
||||
model = str(row.iloc[4]).strip() if len(row) > 4 and not pd.isna(row.iloc[4]) else 'openai/gpt-4o-2024-08-06' # 第五列:模型
|
||||
|
||||
users[username] = {
|
||||
'password': password,
|
||||
'api_key': api_key,
|
||||
'config_file': config_file
|
||||
'config_file': config_file,
|
||||
'model': model
|
||||
}
|
||||
|
||||
print(f"成功加载 {len(users)} 个用户")
|
||||
@ -94,6 +106,7 @@ def create_session(username):
|
||||
'username': username,
|
||||
'api_key': user_data.get('api_key', 'OPENAI_API_KEY'),
|
||||
'config_file': config_file,
|
||||
'model': user_data.get('model', 'openai/gpt-4o-2024-08-06'),
|
||||
'created_at': datetime.now(),
|
||||
'expires_at': datetime.now() + timedelta(hours=24) # 24小时过期
|
||||
}
|
||||
@ -130,6 +143,7 @@ def require_auth(f):
|
||||
request.current_user = session_data['username']
|
||||
request.current_user_api_key = session_data.get('api_key', 'OPENAI_API_KEY')
|
||||
request.current_user_config_file = session_data.get('config_file')
|
||||
request.current_user_model = session_data.get('model', 'openai/gpt-4o-2024-08-06')
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return decorated_function
|
||||
|
||||
@ -48,7 +48,7 @@ def start_translation():
|
||||
|
||||
# 验证数值参数
|
||||
try:
|
||||
slice_length = int(data.get('slice_length', 1000))
|
||||
slice_length = int(data.get('slice_length', 700))
|
||||
if not (200 <= slice_length <= 1500):
|
||||
return jsonify({
|
||||
'success': False,
|
||||
@ -91,9 +91,10 @@ def start_translation():
|
||||
# 处理使用参考语料参数,默认为True以保持向后兼容
|
||||
data['use_reference_corpus'] = data.get('use_reference_corpus', True)
|
||||
|
||||
# 添加用户API_KEY和配置文件到任务参数中
|
||||
# 添加用户API_KEY、配置文件和模型到任务参数中
|
||||
data['user_api_key'] = getattr(request, 'current_user_api_key', 'OPENAI_API_KEY')
|
||||
data['user_config_file'] = getattr(request, 'current_user_config_file', None)
|
||||
data['user_model'] = getattr(request, 'current_user_model', 'openai/gpt-4o-2024-08-06')
|
||||
data['username'] = getattr(request, 'current_user', None)
|
||||
|
||||
# 验证用户配置文件
|
||||
@ -263,21 +264,25 @@ def get_all_tasks():
|
||||
|
||||
|
||||
@translate_bp.route('/translate/model', methods=['GET'])
|
||||
@require_auth
|
||||
def get_current_model():
|
||||
"""
|
||||
获取当前使用的模型信息接口
|
||||
获取当前用户使用的模型信息接口
|
||||
|
||||
Returns:
|
||||
JSON响应包含当前模型信息
|
||||
JSON响应包含当前用户模型信息
|
||||
"""
|
||||
try:
|
||||
from config import get_current_model
|
||||
|
||||
model_name = get_current_model()
|
||||
# 获取用户特定的模型
|
||||
user_model = getattr(request, 'current_user_model', 'openai/gpt-4o-2024-08-06')
|
||||
model_name = get_current_model(user_model)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'model': model_name
|
||||
'model': model_name,
|
||||
'username': getattr(request, 'current_user', None)
|
||||
}), 200
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@ -22,22 +22,20 @@ def get_api_key(user_api_key_env=None):
|
||||
Returns:
|
||||
str: API密钥
|
||||
"""
|
||||
# 如果没有指定用户API_KEY环境变量,使用默认值
|
||||
if not user_api_key_env:
|
||||
user_api_key_env = 'OPENAI_API_KEY'
|
||||
|
||||
|
||||
api_key = os.environ.get(user_api_key_env)
|
||||
if not api_key:
|
||||
raise ValueError(f"环境变量{user_api_key_env}未设置,请设置API密钥")
|
||||
return api_key
|
||||
|
||||
# LLM配置
|
||||
model = "openai/gpt-4o-2024-08-06"
|
||||
def get_config_list(user_api_key_env=None):
|
||||
model = "openai/gpt-4o-2024-08-06" # 默认模型,保持向后兼容
|
||||
def get_config_list(user_api_key_env=None, user_model=None):
|
||||
"""获取LLM配置列表"""
|
||||
api_key = get_api_key(user_api_key_env)
|
||||
selected_model = user_model if user_model else model
|
||||
return [{
|
||||
"model": model,
|
||||
"model": selected_model,
|
||||
"api_key": api_key,
|
||||
"base_url": "https://openrouter.ai/api/v1",
|
||||
"stream": False,
|
||||
@ -46,12 +44,13 @@ def get_config_list(user_api_key_env=None):
|
||||
}]
|
||||
#anthropic/claude-3.5-sonnet
|
||||
#openai/gpt-4o-2024-08-06
|
||||
def get_llm_config_ag2(user_api_key_env=None):
|
||||
def get_llm_config_ag2(user_api_key_env=None, user_model=None):
|
||||
"""获取autogen LLM配置"""
|
||||
api_key = get_api_key(user_api_key_env)
|
||||
selected_model = user_model if user_model else model
|
||||
return LLMConfig(
|
||||
api_type="openai",
|
||||
model= model,
|
||||
model=selected_model,
|
||||
api_key=api_key,
|
||||
base_url="https://openrouter.ai/api/v1"
|
||||
)
|
||||
@ -159,8 +158,8 @@ def get_str_ref(lang):
|
||||
def validate_config():
|
||||
"""验证配置的有效性"""
|
||||
try:
|
||||
# 检查API密钥
|
||||
get_api_key()
|
||||
# 检查API密钥 - 使用默认的环境变量名
|
||||
get_api_key('OPENAI_API_KEY')
|
||||
print("✓ API密钥配置正确")
|
||||
|
||||
# 验证YAML配置
|
||||
@ -186,15 +185,18 @@ def validate_config():
|
||||
print(f"✗ 配置验证失败:{e}")
|
||||
return False
|
||||
|
||||
def get_current_model():
|
||||
def get_current_model(user_model=None):
|
||||
"""
|
||||
获取当前使用的模型名称
|
||||
|
||||
Args:
|
||||
user_model: 用户特定的模型名称
|
||||
|
||||
Returns:
|
||||
str: 当前模型名称
|
||||
"""
|
||||
# 根据translator.py中的实际使用情况,返回get_llm_config_ag2中的模型
|
||||
return model
|
||||
# 根据translator.py中的实际使用情况,返回用户模型或默认模型
|
||||
return user_model if user_model else model
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 配置验证
|
||||
|
||||
@ -5,32 +5,32 @@
|
||||
file_paths:
|
||||
# 术语表路径
|
||||
glossary:
|
||||
en: "C:/Users/v_linzelong/Desktop/Translator/v2/term_en.xlsx"
|
||||
jp: "C:/Users/v_linzelong/Desktop/qq13/名词、术语表.xlsx"
|
||||
en: "../../project/qq13/term/term_en.xlsx"
|
||||
jp: "../../project/qq13/term/term_jp.xlsx"
|
||||
kr: "C:/Users/v_linzelong/Desktop/Translator/v2/term_kr.xlsx"
|
||||
|
||||
# 提示词文件路径
|
||||
prompts:
|
||||
en:
|
||||
system:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_str_en.txt"
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/checker_str_en.txt"
|
||||
- "../../project/g36/prompt/translator_str_en.txt"
|
||||
- "../../project/g36/prompt/checker_str_en.txt"
|
||||
plot:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_plot_en.txt"
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/checker_plot_en.txt"
|
||||
plot2:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_plot_en2.txt"
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/checker_plot_en2.txt"
|
||||
- "../../project/g36/prompt/translator_plot_en2.txt"
|
||||
- "../../project/g36/prompt/checker_plot_en2.txt"
|
||||
jp:
|
||||
system:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_str_jp.txt"
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/checker_str_jp.txt"
|
||||
- "../../project/g36/prompt/translator_plot_jp2.txt"
|
||||
- "../../project/g36/prompt/checker_plot_jp2.txt"
|
||||
plot:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_plot_jp.txt"
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/checker_plot_jp.txt"
|
||||
plot2:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_plot_jp2.txt"
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/checker_plot_jp2.txt"
|
||||
- "../../project/g36/prompt/translator_plot_jp2.txt"
|
||||
- "../../project/g36/prompt/checker_plot_jp2.txt"
|
||||
kr:
|
||||
system:
|
||||
- "C:/Users/v_linzelong/Desktop/Translator/v2/translator_str_kr.txt"
|
||||
|
||||
@ -32,9 +32,10 @@ def translation_process_worker(task_data: dict, progress_queue: multiprocessing.
|
||||
file_path = task_data['file_path']
|
||||
params = task_data['params']
|
||||
|
||||
# 获取用户API_KEY和配置文件
|
||||
# 获取用户API_KEY、配置文件和模型
|
||||
user_api_key = params.get('user_api_key', 'OPENAI_API_KEY')
|
||||
user_config_file = params.get('user_config_file')
|
||||
user_model = params.get('user_model', 'openai/gpt-4o-2024-08-06')
|
||||
username = params.get('username')
|
||||
|
||||
# 创建用户任务目录结构并处理文件路径
|
||||
@ -184,6 +185,7 @@ def translation_process_worker(task_data: dict, progress_queue: multiprocessing.
|
||||
bs=params.get('bs', 20),
|
||||
need_feature=params.get('need_feature', True),
|
||||
user_api_key=user_api_key,
|
||||
user_model=user_model,
|
||||
user_config_loader=user_config_loader,
|
||||
user_glossary_path=user_glossary_path,
|
||||
user_prompt_paths=user_prompt_paths,
|
||||
@ -207,6 +209,7 @@ def translation_process_worker(task_data: dict, progress_queue: multiprocessing.
|
||||
ori_col=params.get('ori_col', 'B'),
|
||||
ori_lang=params.get('ori_lang', 'CN'),
|
||||
user_api_key=user_api_key,
|
||||
user_model=user_model,
|
||||
user_config_loader=user_config_loader,
|
||||
user_glossary_path=user_glossary_path,
|
||||
user_prompt_paths=user_prompt_paths,
|
||||
|
||||
@ -353,5 +353,15 @@
|
||||
"start_time": "251112 20:41:23",
|
||||
"original_length": 18707,
|
||||
"file_name": "G36-1025-ai_20251112_204112_70283c0d.xlsx"
|
||||
},
|
||||
{
|
||||
"start_time": "251113 16:54:24",
|
||||
"original_length": 400,
|
||||
"file_name": "gemini2.5pro-_20251113_165413_d3aaa3a7.xlsx"
|
||||
},
|
||||
{
|
||||
"start_time": "251113 19:27:52",
|
||||
"original_length": 338,
|
||||
"file_name": "G10_20251113_192741_f702f080.xlsx"
|
||||
}
|
||||
]
|
||||
@ -28,7 +28,7 @@ from services.file_path_manager import file_path_manager
|
||||
|
||||
# get_prompt 函数已移除,现在直接使用用户配置的提示词路径
|
||||
|
||||
def create_agent(text_type, lang, t_llm=None, c_llm=None, ori_lang='CN', user_api_key=None, user_prompt_paths=None, username=None, task_id=None):
|
||||
def create_agent(text_type, lang, t_llm=None, c_llm=None, ori_lang='CN', user_api_key=None, user_model=None, user_prompt_paths=None, username=None, task_id=None):
|
||||
"""
|
||||
创建翻译代理
|
||||
|
||||
@ -39,6 +39,7 @@ def create_agent(text_type, lang, t_llm=None, c_llm=None, ori_lang='CN', user_ap
|
||||
c_llm: 校对器LLM配置
|
||||
ori_lang: 原文语言
|
||||
user_api_key: 用户API_KEY环境变量名
|
||||
user_model: 用户模型名称
|
||||
user_prompt_paths: 用户提示词路径列表
|
||||
|
||||
Returns:
|
||||
@ -106,9 +107,9 @@ def create_agent(text_type, lang, t_llm=None, c_llm=None, ori_lang='CN', user_ap
|
||||
print(f"[ERROR] 用户提示词路径不足,需要至少2个路径,实际获得: {user_prompt_paths}")
|
||||
raise ValueError(f"用户提示词路径不足: {user_prompt_paths}")
|
||||
|
||||
# 默认LLM配置,传入用户API_KEY
|
||||
llmconfig = get_llm_config_ag2(user_api_key)
|
||||
print("LLM配置获取成功")
|
||||
# 默认LLM配置,传入用户API_KEY和用户模型
|
||||
llmconfig = get_llm_config_ag2(user_api_key, user_model)
|
||||
print(f"LLM配置获取成功,使用模型: {user_model}")
|
||||
|
||||
def termin(x):
|
||||
print("check over" in x["content"].lower())
|
||||
@ -157,7 +158,7 @@ def create_agent(text_type, lang, t_llm=None, c_llm=None, ori_lang='CN', user_ap
|
||||
|
||||
def translate_sys(file_path, lang, sheet, ori_col='B', sheet_idx=None, slice_length=DEFAULT_SLICE_LENGTH,
|
||||
reference_corpus=None, t_llm=None, c_llm=None, check_turns=DEFAULT_CHECK_TURNS, ori_lang='CN',
|
||||
progress_callback=None, cancel_flag=None, user_api_key=None, is_simple=False,
|
||||
progress_callback=None, cancel_flag=None, user_api_key=None, user_model=None, is_simple=False,
|
||||
user_glossary_path=None, user_prompt_paths=None, username=None, task_id=None):
|
||||
"""
|
||||
系统文本翻译函数(支持简单翻译模式)
|
||||
@ -271,7 +272,7 @@ def translate_sys(file_path, lang, sheet, ori_col='B', sheet_idx=None, slice_len
|
||||
|
||||
# 根据is_simple参数选择代理类型
|
||||
agent_type = "simple" if is_simple else "sys"
|
||||
translator, user_proxy, checker = create_agent(agent_type, lang, t_llm, c_llm, ori_lang, user_api_key, user_prompt_paths, username, task_id)
|
||||
translator, user_proxy, checker = create_agent(agent_type, lang, t_llm, c_llm, ori_lang, user_api_key, user_model, user_prompt_paths, username, task_id)
|
||||
print(f"翻译代理创建完成,切片 {slice_idx}")
|
||||
|
||||
print(f"注册嵌套聊天,切片 {slice_idx}")
|
||||
@ -317,7 +318,7 @@ def translate_sys(file_path, lang, sheet, ori_col='B', sheet_idx=None, slice_len
|
||||
|
||||
def translate_plot2(file_path, all_index, lang, pos, head=False, t_llm=None, c_llm=None,
|
||||
bs=DEFAULT_BATCH_SIZE, check_turns=DEFAULT_CHECK_TURNS, reference_corpus=None,
|
||||
need_feature=False, sheet_idx=None, user_api_key=None,
|
||||
need_feature=False, sheet_idx=None, user_api_key=None, user_model=None,
|
||||
user_glossary_path=None, user_prompt_paths=None, user_feature_prompt_path=None,
|
||||
username=None, task_id=None):
|
||||
"""
|
||||
@ -419,7 +420,7 @@ def translate_plot2(file_path, all_index, lang, pos, head=False, t_llm=None, c_l
|
||||
def reflection_message(recipient, messages, sender, config):
|
||||
return f"需要翻译的原文: \n{ori_text}\n需要检查的译文: \n{recipient.chat_messages_for_summary(sender)[-1]['content'] }\n用词与语气:\n \"\"\"\n{feature}\n\"\"\"\n术语表:\n {glossary}\n 术语表结束"
|
||||
|
||||
translator, user_proxy, checker = create_agent("plot2", lang, t_llm, c_llm, 'CN', user_api_key, user_prompt_paths, username, task_id)
|
||||
translator, user_proxy, checker = create_agent("plot2", lang, t_llm, c_llm, 'CN', user_api_key, user_model, user_prompt_paths, username, task_id)
|
||||
|
||||
user_proxy.register_nested_chats(
|
||||
[{"recipient": checker, "message": reflection_message, "summary_method": "last_msg", "max_turns": 1}],
|
||||
@ -450,7 +451,7 @@ def translate_plot2(file_path, all_index, lang, pos, head=False, t_llm=None, c_l
|
||||
|
||||
def translate_simple(file_path, lang, sheet, ori_col='B', sheet_idx=None, slice_length=DEFAULT_SLICE_LENGTH,
|
||||
reference_corpus=None, t_llm=None, c_llm=None, ori_lang='CN',
|
||||
progress_callback=None, cancel_flag=None, user_api_key=None,
|
||||
progress_callback=None, cancel_flag=None, user_api_key=None, user_model=None,
|
||||
user_glossary_path=None, user_prompt_paths=None, username=None, task_id=None):
|
||||
"""
|
||||
一般文本翻译函数(简化版,调用translate_sys实现)
|
||||
@ -489,6 +490,7 @@ def translate_simple(file_path, lang, sheet, ori_col='B', sheet_idx=None, slice_
|
||||
progress_callback=progress_callback,
|
||||
cancel_flag=cancel_flag,
|
||||
user_api_key=user_api_key,
|
||||
user_model=user_model,
|
||||
is_simple=True, # 关键参数:启用简单翻译模式
|
||||
user_glossary_path=user_glossary_path,
|
||||
user_prompt_paths=user_prompt_paths,
|
||||
@ -517,12 +519,14 @@ def translate_start(file_path, lang, tran_type, sheet, reference_corpus=None, sh
|
||||
**kwargs: 其他参数
|
||||
"""
|
||||
user_api_key = kwargs.get('user_api_key')
|
||||
user_model = kwargs.get('user_model')
|
||||
user_config_loader = kwargs.get('user_config_loader')
|
||||
user_glossary_path = kwargs.get('user_glossary_path')
|
||||
user_prompt_paths = kwargs.get('user_prompt_paths')
|
||||
user_feature_prompt_path = kwargs.get('user_feature_prompt_path')
|
||||
|
||||
print(f"[DEBUG] translate_start 接收到用户配置参数:")
|
||||
print(f" - user_model: {user_model}")
|
||||
print(f" - user_glossary_path: {user_glossary_path}")
|
||||
print(f" - user_prompt_paths: {user_prompt_paths}")
|
||||
print(f" - user_feature_prompt_path: {user_feature_prompt_path}")
|
||||
@ -534,7 +538,7 @@ def translate_start(file_path, lang, tran_type, sheet, reference_corpus=None, sh
|
||||
check_turns=kwargs.get('check_turns', 2), slice_length=kwargs.get('slice_length', 1200),
|
||||
ori_col=kwargs.get('ori_col'), ori_lang=kwargs.get('ori_lang'),
|
||||
progress_callback=progress_callback, cancel_flag=cancel_flag, user_api_key=user_api_key,
|
||||
user_glossary_path=user_glossary_path, user_prompt_paths=user_prompt_paths,
|
||||
user_model=user_model, user_glossary_path=user_glossary_path, user_prompt_paths=user_prompt_paths,
|
||||
username=kwargs.get('username'), task_id=kwargs.get('task_id')
|
||||
)
|
||||
append_to_log(start_time, ori_len, filename=os.path.basename(file_path))
|
||||
@ -553,6 +557,7 @@ def translate_start(file_path, lang, tran_type, sheet, reference_corpus=None, sh
|
||||
need_feature=kwargs.get('need_feature', True),
|
||||
sheet_idx=sheet_idx,
|
||||
user_api_key=user_api_key,
|
||||
user_model=user_model,
|
||||
user_glossary_path=user_glossary_path,
|
||||
user_prompt_paths=user_prompt_paths,
|
||||
user_feature_prompt_path=user_feature_prompt_path,
|
||||
@ -568,7 +573,7 @@ def translate_start(file_path, lang, tran_type, sheet, reference_corpus=None, sh
|
||||
file_path, lang, sheet=sheet, sheet_idx=sheet_idx, reference_corpus=reference_corpus,
|
||||
slice_length=kwargs.get('slice_length', 1200), ori_col=kwargs.get('ori_col'),
|
||||
ori_lang=kwargs.get('ori_lang'), progress_callback=progress_callback, cancel_flag=cancel_flag,
|
||||
user_api_key=user_api_key, user_glossary_path=user_glossary_path, user_prompt_paths=user_prompt_paths,
|
||||
user_api_key=user_api_key, user_model=user_model, user_glossary_path=user_glossary_path, user_prompt_paths=user_prompt_paths,
|
||||
username=kwargs.get('username'), task_id=kwargs.get('task_id')
|
||||
)
|
||||
append_to_log(start_time, ori_len, filename=os.path.basename(file_path))
|
||||
|
||||
@ -2,12 +2,17 @@
|
||||
echo 启动翻译工具后端服务...
|
||||
echo.
|
||||
|
||||
REM 端口配置 - 可以在这里修改端口号
|
||||
set FRONTEND_PORT=3100
|
||||
set BACKEND_PORT=5000
|
||||
REM 从配置文件读取配置
|
||||
echo 正在读取配置文件...
|
||||
|
||||
REM 白名单配置 - 设置为1启用,0关闭
|
||||
set ENABLE_WHITELIST=0
|
||||
REM 读取服务器配置
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "frontend_port=" start_config.ini`) do set FRONTEND_PORT=%%a
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "backend_port=" start_config.ini`) do set BACKEND_PORT=%%a
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "enable_whitelist=" start_config.ini`) do set ENABLE_WHITELIST=%%a
|
||||
|
||||
REM 读取环境配置
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "conda_activate_script=" start_config.ini`) do set CONDA_ACTIVATE_SCRIPT=%%a
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "conda_env_path=" start_config.ini`) do set CONDA_ENV_PATH=%%a
|
||||
|
||||
echo 前端端口: %FRONTEND_PORT%
|
||||
echo 后端端口: %BACKEND_PORT%
|
||||
@ -21,10 +26,10 @@ echo.
|
||||
cd backend
|
||||
|
||||
echo 激活conda环境...
|
||||
call D:\miniconda\Scripts\activate.bat D:\miniconda\envs\ag2forApp
|
||||
call "%CONDA_ACTIVATE_SCRIPT%" "%CONDA_ENV_PATH%"
|
||||
if %errorlevel% neq 0 (
|
||||
echo 错误: 无法激活conda环境 ag2forApp
|
||||
echo 请确保环境路径正确: D:\miniconda\envs\ag2forApp
|
||||
echo 错误: 无法激活conda环境 %CONDA_ENV_PATH%
|
||||
echo 请确保环境路径正确: %CONDA_ENV_PATH%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
@ -43,7 +48,7 @@ echo.
|
||||
echo 启动Flask服务器...
|
||||
echo 后端地址: http://localhost:%BACKEND_PORT%
|
||||
echo WebSocket地址: ws://localhost:%BACKEND_PORT%/socket.io/
|
||||
echo 使用conda环境: D:\miniconda\envs\ag2forApp
|
||||
echo 使用conda环境: %CONDA_ENV_PATH%
|
||||
echo 按 Ctrl+C 停止服务
|
||||
echo.
|
||||
|
||||
|
||||
8
start_config.ini
Normal file
8
start_config.ini
Normal file
@ -0,0 +1,8 @@
|
||||
[server]
|
||||
frontend_port=3100
|
||||
backend_port=5000
|
||||
enable_whitelist=0
|
||||
|
||||
[environment]
|
||||
conda_activate_script=D:\miniconda\Scripts\activate.bat
|
||||
conda_env_path=D:\miniconda\envs\ag2forApp
|
||||
@ -1,9 +1,10 @@
|
||||
@echo off
|
||||
|
||||
|
||||
REM 端口配置 - 可以在这里修改端口号
|
||||
set FRONTEND_PORT=3100
|
||||
set BACKEND_PORT=5000
|
||||
REM 从配置文件读取端口配置
|
||||
echo 正在读取配置文件...
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "frontend_port=" start_config.ini`) do set FRONTEND_PORT=%%a
|
||||
for /f "usebackq tokens=2 delims==" %%a in (`findstr "backend_port=" start_config.ini`) do set BACKEND_PORT=%%a
|
||||
|
||||
echo 当前目录: %CD%
|
||||
echo 前端端口: %FRONTEND_PORT%
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
|
||||
qq13,qq13bili,OPENROUTER_QQ13,qq13_config.yaml
|
||||
admin,admin123,OPENAI_API_KEY,admin_config.yaml
|
||||
g36,g36bili,OPENAI_API_KEY,g36.yaml
|
||||
username,password,api_key_env,config_file,model
|
||||
qq13,qq13bili,OPENROUTER_QQ13,qq13_config.yaml,deepseek/deepseek-v3.1-terminus
|
||||
admin,admin123,OPENAI_API_KEY,admin_config.yaml,openai/gpt-4o-2024-08-06
|
||||
g36,g36bili,OPENAI_API_KEY,g36.yaml,openai/gpt-4o-2024-08-06
|
||||
# anthropic/claude-3.5-sonnet openai/gpt-4o-2024-08-06 deepseek/deepseek-v3.1-terminus
|
||||
|
Loading…
x
Reference in New Issue
Block a user