测试修改
This commit is contained in:
@@ -6,7 +6,8 @@ RAG Core 配置管理模块
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
import dotenv
|
||||
dotenv.load_dotenv()
|
||||
|
||||
# ========== 辅助函数:类型转换 ==========
|
||||
def _get_str(key: str) -> str | None:
|
||||
|
||||
@@ -21,6 +21,9 @@ class LlamaCppEmbedder:
|
||||
self.base_url = LLAMACPP_EMBEDDING_URL
|
||||
self.api_key = LLAMACPP_API_KEY
|
||||
self.model = model
|
||||
print(f"初始化 base_url: { self.base_url}")
|
||||
|
||||
|
||||
|
||||
def as_langchain_embeddings(self) -> Embeddings:
|
||||
"""创建 LangChain 兼容的嵌入实例。"""
|
||||
@@ -41,13 +44,14 @@ class LlamaCppEmbedder:
|
||||
|
||||
def _call_embedding_api(self, texts: List[str]) -> List[List[float]]:
|
||||
"""直接调用 llama.cpp 嵌入 API。"""
|
||||
headers = {"Content-Type": "application/json"}
|
||||
if self.api_key:
|
||||
headers["Authorization"] = f"Bearer {self.api_key}"
|
||||
|
||||
base = self.base_url.rstrip("/")
|
||||
if not base.endswith("/v1"):
|
||||
base = base + "/v1"
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
if self.api_key:
|
||||
headers["Authorization"] = f"Bearer {self.api_key}"
|
||||
|
||||
payload = {
|
||||
"input": texts,
|
||||
|
||||
Reference in New Issue
Block a user