feat: load .env file via python-dotenv for API key management
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# CodeGraph data files — local to each machine, not for committing.
|
||||
# Ignore everything in .codegraph/ except this file itself, so transient
|
||||
# files (the database, daemon.pid, sockets, logs) never show up in git.
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,8 @@
|
||||
# md-vector-db 环境变量配置
|
||||
# 复制此文件为 .env 并填入实际值
|
||||
|
||||
# 嵌入 API 密钥 (embed.mode=api 时使用)
|
||||
EMBED_API_KEY=sk-your-key-here
|
||||
|
||||
# HTTP API 认证密钥 (不设置则跳过认证)
|
||||
MD_VECTOR_API_KEY=your-secret-key
|
||||
@@ -11,6 +11,7 @@ dependencies = [
|
||||
"pyyaml>=6.0",
|
||||
"markdown-it-py>=3.0.0",
|
||||
"typer>=0.12.0",
|
||||
"python-dotenv>=1.2.2",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
@@ -5,8 +5,13 @@ import os
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
import yaml
|
||||
|
||||
# 加载 .env 文件 (若存在)
|
||||
load_dotenv()
|
||||
|
||||
# 默认配置文件路径
|
||||
DEFAULT_CONFIG_PATH = "config.yaml"
|
||||
|
||||
|
||||
@@ -873,6 +873,7 @@ dependencies = [
|
||||
{ name = "chromadb" },
|
||||
{ name = "fastapi" },
|
||||
{ name = "markdown-it-py" },
|
||||
{ name = "python-dotenv" },
|
||||
{ name = "pyyaml" },
|
||||
{ name = "sentence-transformers" },
|
||||
{ name = "typer" },
|
||||
@@ -892,6 +893,7 @@ requires-dist = [
|
||||
{ name = "httpx", marker = "extra == 'dev'", specifier = ">=0.27.0" },
|
||||
{ name = "markdown-it-py", specifier = ">=3.0.0" },
|
||||
{ name = "pytest", marker = "extra == 'dev'", specifier = ">=8.0" },
|
||||
{ name = "python-dotenv", specifier = ">=1.2.2" },
|
||||
{ name = "pyyaml", specifier = ">=6.0" },
|
||||
{ name = "sentence-transformers", specifier = ">=3.0.0" },
|
||||
{ name = "typer", specifier = ">=0.12.0" },
|
||||
|
||||
Reference in New Issue
Block a user