Init
This commit is contained in:
@@ -4,10 +4,8 @@ import chromadb
|
||||
from dotenv import load_dotenv
|
||||
from langchain_openai import AzureOpenAIEmbeddings, OpenAIEmbeddings
|
||||
|
||||
# 加载.env文件中的环境变量
|
||||
load_dotenv()
|
||||
|
||||
# 获取配置的LLM供应商
|
||||
LLM_PROVIDER = os.getenv("LLM_PROVIDER", "openai").lower()
|
||||
|
||||
embedding_model = None
|
||||
@@ -15,7 +13,6 @@ embedding_model = None
|
||||
print(f"--- [Core] Initializing Embeddings with provider: {LLM_PROVIDER} ---")
|
||||
|
||||
if LLM_PROVIDER == "azure":
|
||||
# --- Azure OpenAI 配置 ---
|
||||
required_vars = [
|
||||
"AZURE_OPENAI_ENDPOINT", "AZURE_OPENAI_API_KEY",
|
||||
"OPENAI_API_VERSION", "AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME"
|
||||
@@ -31,7 +28,6 @@ if LLM_PROVIDER == "azure":
|
||||
)
|
||||
|
||||
elif LLM_PROVIDER == "openai":
|
||||
# --- 标准 OpenAI 配置 ---
|
||||
if not os.getenv("OPENAI_API_KEY"):
|
||||
raise ValueError("OPENAI_API_KEY is not set for the 'openai' provider.")
|
||||
|
||||
@@ -44,7 +40,6 @@ else:
|
||||
raise ValueError(f"Unsupported LLM_PROVIDER: {LLM_PROVIDER}. Please use 'azure' or 'openai'.")
|
||||
|
||||
|
||||
# 初始化ChromaDB客户端 (无变化)
|
||||
client = chromadb.PersistentClient(path="./chroma_db")
|
||||
vector_store = client.get_or_create_collection(
|
||||
name="documents",
|
||||
|
||||
Reference in New Issue
Block a user