feat(milvus): Introduce Milvus vector database API for read-only access

- Added a new API endpoint to list collections in the Milvus vector database, providing metadata such as titles, descriptions, and sample data.
- Integrated the new Milvus router into the main application, ensuring it is accessible through the API.
- Updated the JSON serialization logic to handle decimal precision for financial data, maintaining accuracy in API responses.
- Enhanced the frontend with a new Knowledge Base page to display vector collections, including sample previews and collection details.
- Updated routing and menu structures to include the new Knowledge Base feature, improving navigation within the application.
This commit is contained in:
2026-09-14 10:27:02 +08:00
parent c790387717
commit c6a2bfd4f7
15 changed files with 535 additions and 146 deletions
+18 -10
View File
@@ -28,9 +28,9 @@
货币基金(`PROD-000001` 现金宝货币)
------------------------------------------------------------------
真实业务中货币基金**单位净值恒为 1.0000 元**,收益以份额结转,不存在净值序列
(实测:天弘余额宝 000198、广发钱袋子 000509 在该接口均无 `Data_netWorthTrend`)。
故货基不联网,直接按真实业务生成恒定 1.0000、日涨幅 0。
真实业务中货基**展示**单位净值常为 1.0000,但该接口也无可用 `Data_netWorthTrend`。
演示库不与 06 写死平线:货基净值与 `seed_nav_history.py` / `07-seed-nav-history.sql`
同源(锚定 1.0020 附近、低 beta 微波动),便于行情页看到走势与日涨跌。
用法
------------------------------------------------------------------
@@ -74,15 +74,20 @@ NAV_SOURCE: dict[str, tuple[str, str, str]] = {
"PROD-PRIV01": ("519062", "海富通阿尔法对冲混合A", "private_fund/R4:量化对冲,日波动 0.33%"),
}
# 货币基金:净值恒为 1.0000(真实业务,不联网)
# 货币基金:不联网,曲线与 seed_nav_history / 07-seed 同源
MONEY_FUNDS: dict[str, str] = {
"PROD-000001": "现金宝货币(money/R1:货基单位净值恒为 1 元,收益以份额结转)",
"PROD-000001": "现金宝货币(money/R1:演示用低波净值,见 seed_nav_history.py)",
}
DEFAULT_OUT = Path(__file__).with_name("06-seed-nav.sql")
DEFAULT_DAYS = 60
TIMEOUT = 30
_SCRIPT_DIR = Path(__file__).resolve().parent
if str(_SCRIPT_DIR) not in sys.path:
sys.path.insert(0, str(_SCRIPT_DIR))
from seed_nav_history import nav_rows_for_product_dates # noqa: E402
# ── 抓取与解析 ───────────────────────────────────────────────────────────
def fetch_js(code: str, cache_dir: Path | None) -> str:
@@ -119,7 +124,10 @@ def build_sql(rows: list[tuple[str, dt.date, float, float]], fetched_at: str) ->
f"-- {pid:<13} <- {code} {name}({why})"
for pid, (code, name, why) in sorted(NAV_SOURCE.items())
)
money = "\n".join(f"-- {pid:<13} <- 恒定 1.0000({why})" for pid, why in sorted(MONEY_FUNDS.items()))
money = "\n".join(
f"-- {pid:<13} <- 演示曲线({why};与 07-seed-nav-history 同源)"
for pid, why in sorted(MONEY_FUNDS.items())
)
dates = [r[1] for r in rows]
head = (
"USE jinrong_core;\n\n"
@@ -185,13 +193,13 @@ def main(argv: list[str] | None = None) -> int:
rows.append((pid, day, nav, chg))
print(f"[OK] {pid} <- {code} {name}:{len(series[-args.days:])} 条,最新 {series[-1][0]} {series[-1][1]}")
# 货币基金:净值恒定 1.0000
# 货币基金:与 07 种子同源的低波演示曲线(勿再写死 1.0000/0)
if rows:
money_days = sorted({r[1] for r in rows})
for pid in sorted(MONEY_FUNDS):
for day in money_days:
rows.append((pid, day, 1.0000, 0.0))
print(f"[OK] {pid} <- 货基恒定净值 1.0000:{len(money_days)} 条")
sim = nav_rows_for_product_dates(pid, money_days)
rows.extend(sim)
print(f"[OK] {pid} <- 货基演示曲线(seed_nav_history):{len(sim)} 条")
if failed:
print("\n[FAIL] 以下产品拉取失败:", file=sys.stderr)