修复ai
This commit is contained in:
@@ -35,6 +35,7 @@ import sys
|
||||
if _REPO_ROOT not in sys.path:
|
||||
sys.path.insert(0, _REPO_ROOT)
|
||||
from ai_client import ai_generate, ai_review, ai_short_advice
|
||||
from ai_review_lib import build_journal_ai_chart_path, collect_images_for_ai_review
|
||||
from journal_chart_lib import (
|
||||
JOURNAL_CHART_DEFAULT_LIMIT,
|
||||
JOURNAL_CHART_DEFAULT_TF1,
|
||||
@@ -7230,6 +7231,18 @@ def manual_transfer():
|
||||
return redirect("/")
|
||||
|
||||
|
||||
def _journal_ai_chart_builder(row):
|
||||
return build_journal_ai_chart_path(
|
||||
row,
|
||||
app.config["UPLOAD_FOLDER"],
|
||||
order_chart_enabled=ORDER_CHART_ENABLED,
|
||||
normalize_exchange_symbol_fn=lambda c: normalize_exchange_symbol(normalize_symbol_input(c)),
|
||||
generate_chart_fn=generate_multi_timeframe_chart_png,
|
||||
local_datetime_to_ms_fn=_local_input_datetime_to_ms,
|
||||
now_ts_ms_fn=lambda: int(app_now().timestamp() * 1000),
|
||||
)
|
||||
|
||||
|
||||
@app.route("/ai_daily_review", methods=["POST"])
|
||||
@login_required
|
||||
def ai_daily_review():
|
||||
@@ -7248,14 +7261,11 @@ def ai_daily_review():
|
||||
text += _journal_row_lines_for_ai(idx, row)
|
||||
text += "\n"
|
||||
|
||||
image_paths = []
|
||||
for row in rows:
|
||||
img = row["image"]
|
||||
if not img:
|
||||
continue
|
||||
img_path = os.path.join(app.config["UPLOAD_FOLDER"], img)
|
||||
if os.path.exists(img_path):
|
||||
image_paths.append(img_path)
|
||||
image_paths = collect_images_for_ai_review(
|
||||
rows,
|
||||
app.config["UPLOAD_FOLDER"],
|
||||
build_chart_if_missing=_journal_ai_chart_builder,
|
||||
)
|
||||
ai_result = ai_review(text, "每日", image_paths=image_paths)
|
||||
full = f"【AI日复盘 {date}】\n{ai_result}\n\n原始记录:\n{text}"
|
||||
conn = get_db()
|
||||
@@ -7287,14 +7297,11 @@ def ai_weekly_review():
|
||||
text += _journal_row_lines_for_ai(idx, row)
|
||||
text += "\n"
|
||||
|
||||
image_paths = []
|
||||
for row in rows:
|
||||
img = row["image"]
|
||||
if not img:
|
||||
continue
|
||||
img_path = os.path.join(app.config["UPLOAD_FOLDER"], img)
|
||||
if os.path.exists(img_path):
|
||||
image_paths.append(img_path)
|
||||
image_paths = collect_images_for_ai_review(
|
||||
rows,
|
||||
app.config["UPLOAD_FOLDER"],
|
||||
build_chart_if_missing=_journal_ai_chart_builder,
|
||||
)
|
||||
ai_result = ai_review(text, "周度", image_paths=image_paths)
|
||||
full = f"【AI周复盘 {start_date}~{end_date}】\n{ai_result}\n\n原始记录:\n{text}"
|
||||
conn = get_db()
|
||||
|
||||
Reference in New Issue
Block a user