This commit is contained in:
parent
d46ff27835
commit
636bd451f5
|
|
@ -3,7 +3,7 @@ from typing import List # 导入 List 用于类型注解
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import faiss
|
import faiss
|
||||||
from llama_index import SimpleDirectoryReader, VectorStoreIndex, ServiceContext, StorageContext, load_index_from_storage
|
from llama_index import SimpleDirectoryReader, VectorStoreIndex, ServiceContext, StorageContext, load_index_from_storage, Settings
|
||||||
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
||||||
from llama_index.vector_stores.faiss import FaissVectorStore
|
from llama_index.vector_stores.faiss import FaissVectorStore
|
||||||
from app.core.config import settings # 导入应用配置
|
from app.core.config import settings # 导入应用配置
|
||||||
|
|
@ -135,6 +135,9 @@ def build_user_index(user_id: str):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# 禁用 LLM
|
||||||
|
Settings.llm = None
|
||||||
|
|
||||||
# 构建索引,并使用 `storage_context.persist()` 方法保存索引
|
# 构建索引,并使用 `storage_context.persist()` 方法保存索引
|
||||||
index = VectorStoreIndex.from_documents(
|
index = VectorStoreIndex.from_documents(
|
||||||
documents,
|
documents,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue