📘 **TELUS Agriculture & Consumer Goods** 如何通过 **Haystack Agents** 转变促销交易

集成:LanceDB Haystack

由 LanceDB 支持的 DocumentStore

作者
Alan Meeson

目录

概述

LanceDB-Haystack 是一个嵌入式 LanceDB 支持的 Document Store,用于 Haystack

安装

目前通过 pip 从 GitHub 安装 LanceDB-Haystack 的最简单方法是

pip install lancedb-haystack

使用

import pyarrow as pa
from lancedb_haystack import LanceDBDocumentStore
from lancedb_haystack import LanceDBEmbeddingRetriever, LanceDBFTSRetriever

# Declare the metadata fields schema, this lets us filter using it.
# See: https://arrow.apache.ac.cn/docs/python/api/datatypes.html
metadata_schema = pa.struct([
  ('title', pa.string()),    
  ('publication_date', pa.timestamp('s')),
  ('page_number', pa.int32()),
  ('topics', pa.list_(pa.string()))
])

# Create the DocumentStore
document_store = LanceDBDocumentStore(
  database='my_database', 
  table_name="documents", 
  metadata_schema=metadata_schema, 
  embedding_dims=384
)

# Create an embedding retriever
embedding_retriever = LanceDBEmbeddingRetriever(document_store)

# Create a Full Text Search retriever
fts_retriever = LanceDBFTSRetriever(document_store)

另请参阅 examples/pipeline-usage.ipynb 以获取完整的示例,以及 API 参考

许可证

Apache License 2.0