++
This commit is contained in:
+27
-7
@@ -16,9 +16,9 @@ USE_AI = 1
|
||||
SILICONFLOW_API_KEY = "sk-pvdiisdowmuwkrpnxsrlhxaovicqibmlljwrwwvbbdjaitdl"
|
||||
SILICONFLOW_BASE_URL = "https://api.siliconflow.cn/v1"
|
||||
MODELS = [
|
||||
'Pro/deepseek-ai/DeepSeek-V3.1-Terminus',
|
||||
# 'Pro/deepseek-ai/DeepSeek-V3.1-Terminus',
|
||||
# 'deepseek-ai/DeepSeek-V3.2-Exp',
|
||||
# 'Qwen/Qwen3-VL-235B-A22B-Instruct',
|
||||
'Qwen/Qwen3-VL-235B-A22B-Instruct',
|
||||
# 'MiniMaxAI/MiniMax-M2',
|
||||
# 'zai-org/GLM-4.6',
|
||||
# 'inclusionAI/Ring-flash-2.0',
|
||||
@@ -27,6 +27,21 @@ MODELS = [
|
||||
# 'inclusionAI/Ring-flash-2.0',
|
||||
]
|
||||
|
||||
def load_role_system():
|
||||
"""读取role_system.txt文件"""
|
||||
try:
|
||||
role_system_file = os.path.join(NEW_STORY_PROMPT, 'role_system.txt')
|
||||
if os.path.exists(role_system_file):
|
||||
with open(role_system_file, 'r', encoding='utf-8') as f:
|
||||
result = f.read()
|
||||
else:
|
||||
result = ""
|
||||
return result + "\n"
|
||||
except Exception as e:
|
||||
print(f"读取结束提示词文件出错: {e}")
|
||||
return ""
|
||||
|
||||
|
||||
def load_prompt():
|
||||
"""读取多份financial_logic_X.txt文件(X为0-9的数字)"""
|
||||
result = ""
|
||||
@@ -65,7 +80,7 @@ def end_prompt():
|
||||
print(f"读取结束提示词文件出错: {e}")
|
||||
return ""
|
||||
|
||||
def call_siliconflow(prompt, model):
|
||||
def call_siliconflow(prompt, model, role_system):
|
||||
try:
|
||||
client = openai.OpenAI(
|
||||
api_key=SILICONFLOW_API_KEY,
|
||||
@@ -75,7 +90,7 @@ def call_siliconflow(prompt, model):
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
messages=[
|
||||
{"role": "system", "content": "你是一个专业的量化投资专家,编写创新的金融逻辑/策略"},
|
||||
{"role": "system", "content": role_system},
|
||||
{"role": "user", "content": prompt}
|
||||
],
|
||||
temperature=TEMPERATURE
|
||||
@@ -161,7 +176,7 @@ def save_ai_result(ai_result, model_name):
|
||||
|
||||
# 保存结果到文件
|
||||
with open(filepath, 'w', encoding='utf-8') as f:
|
||||
f.write(ai_result)
|
||||
f.write(ai_result + "\n\n")
|
||||
|
||||
print(f"AI结果已保存到: {filepath}")
|
||||
return filepath
|
||||
@@ -172,7 +187,12 @@ def save_ai_result(ai_result, model_name):
|
||||
|
||||
def main():
|
||||
finally_prompt = ""
|
||||
|
||||
|
||||
role_system = load_role_system()
|
||||
|
||||
if role_system:
|
||||
finally_prompt += role_system
|
||||
|
||||
prompt = load_prompt()
|
||||
|
||||
if prompt:
|
||||
@@ -187,7 +207,7 @@ def main():
|
||||
|
||||
if USE_AI:
|
||||
for model in MODELS:
|
||||
result = call_siliconflow(finally_prompt, model)
|
||||
result = call_siliconflow(finally_prompt, model, role_system)
|
||||
save_ai_result(result, model)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user