Qdrant Reader¶
In [ ]:
Copied!
%pip install llama-index-readers-qdrant
%pip install llama-index-readers-qdrant
In [ ]:
Copied!
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
如果您在colab上打开这个笔记本,您可能需要安装LlamaIndex 🦙。
In [ ]:
Copied!
!pip install llama-index
!pip install llama-index
In [ ]:
Copied!
from llama_index.readers.qdrant import QdrantReader
from llama_index.readers.qdrant import QdrantReader
In [ ]:
Copied!
reader = QdrantReader(host="localhost")
reader = QdrantReader(host="localhost")
In [ ]:
Copied!
# 查询向量是查询的嵌入表示
# 示例查询向量:
# query_vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]
query_vector = [n1, n2, n3, ...]
# 查询向量是查询的嵌入表示
# 示例查询向量:
# query_vector=[0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3]
query_vector = [n1, n2, n3, ...]
In [ ]:
Copied!
# 注意:必需参数为 collection_name, query_vector。
# 请参阅 Python 客户端:https://github.com/qdrant/qdrant_client
# 了解更多细节。
documents = reader.load_data(
collection_name="demo", query_vector=query_vector, limit=5
)
# 注意:必需参数为 collection_name, query_vector。
# 请参阅 Python 客户端:https://github.com/qdrant/qdrant_client
# 了解更多细节。
documents = reader.load_data(
collection_name="demo", query_vector=query_vector, limit=5
)
创建索引¶
In [ ]:
Copied!
index = SummaryIndex.from_documents(documents)
index = SummaryIndex.from_documents(documents)
In [ ]:
Copied!
# 将日志级别设置为DEBUG,以获得更详细的输出
query_engine = index.as_query_engine()
response = query_engine.query("<query_text>")
# 将日志级别设置为DEBUG,以获得更详细的输出
query_engine = index.as_query_engine()
response = query_engine.query("")
In [ ]:
Copied!
display(Markdown(f"<b>{response}</b>"))
display(Markdown(f"{response}"))