feat: 使用百炼的嵌入模型服务
This commit is contained in:
@@ -37,7 +37,7 @@ def create_llama_index_llm(platform_code='huoshan-doubao', temperature=0.5):
|
||||
)
|
||||
|
||||
|
||||
def create_embeddings(platform_code="huoshan-embedding-240715"):
|
||||
def create_embeddings(platform_code="bailian-embedding"):
|
||||
"""
|
||||
创建自定义嵌入模型实例
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from typing import List, Optional
|
||||
|
||||
from llama_index.core import Document, VectorStoreIndex
|
||||
@@ -45,7 +46,9 @@ class MilvusService:
|
||||
)
|
||||
from llama_index.core.node_parser import HierarchicalNodeParser
|
||||
parser = HierarchicalNodeParser.from_defaults(chunk_sizes=[2048, 512, 128])
|
||||
nodes = await parser.aget_nodes_from_documents(documents)
|
||||
# nodes = await parser.aget_nodes_from_documents(documents)
|
||||
# 使用同步方法并包装在 asyncio.to_thread 中
|
||||
nodes = await asyncio.to_thread(parser.get_nodes_from_documents,documents)
|
||||
await vector_index.ainsert_nodes(nodes)
|
||||
return vector_index
|
||||
|
||||
|
||||
Reference in New Issue
Block a user