mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-07 05:52:15 +00:00
Add template for self-query-qdrant (#12795)
This PR adds a self-querying template using Qdrant as a vector store. The template uses an artificial dataset and was implemented in a way that simplifies passing different components and choosing LLM and embedding providers. --------- Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
27
templates/self-query-qdrant/self_query_qdrant/helper.py
Normal file
27
templates/self-query-qdrant/self_query_qdrant/helper.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from string import Formatter
|
||||
from typing import List
|
||||
|
||||
from langchain.schema import Document
|
||||
|
||||
document_template = """
|
||||
PASSAGE: {page_content}
|
||||
METADATA: {metadata}
|
||||
"""
|
||||
|
||||
|
||||
def combine_documents(documents: List[Document]) -> str:
|
||||
"""
|
||||
Combine a list of documents into a single string that might be passed further down
|
||||
to a language model.
|
||||
:param documents: list of documents to combine
|
||||
:return:
|
||||
"""
|
||||
formatter = Formatter()
|
||||
return "\n\n".join(
|
||||
formatter.format(
|
||||
document_template,
|
||||
page_content=document.page_content,
|
||||
metadata=document.metadata,
|
||||
)
|
||||
for document in documents
|
||||
)
|
Reference in New Issue
Block a user