fix: remove api_key from config.yaml, read from EMBED_API_KEY env var; unify config path constant

This commit is contained in:
2026-07-05 01:30:46 +08:00
parent 10f9aaede4
commit 5dcf1eed52
6 changed files with 928 additions and 9 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ from pathlib import Path
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from src.core.config import load_config, EmbedConfig
from src.core.config import load_config, EmbedConfig, DEFAULT_CONFIG_PATH
from src.core.db import VectorDB
from src.core.embedder import create_embedder
from src.core.ingest import DocumentIngestor
@@ -42,9 +42,9 @@ def _get_db():
def _get_embedder():
global _embedder
if _embedder is None:
# 先尝试从 config.yaml 加载, 失败则用默认 local
# 先尝试从配置文件加载, 失败则用默认 local
try:
cfg = load_config("config.yaml")
cfg = load_config(DEFAULT_CONFIG_PATH)
embed_cfg = cfg.embed
except Exception:
embed_cfg = EmbedConfig(mode="local")
@@ -56,7 +56,7 @@ def _init_services():
global _searcher, _ingestor
collection = os.getenv("MD_VECTOR_DB_COLLECTION", "markdown_docs")
try:
cfg = load_config("config.yaml")
cfg = load_config(DEFAULT_CONFIG_PATH)
collection = cfg.chroma.collection_name
except Exception:
pass