mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-30 11:39:03 +00:00
langchain[patch]: Fix create_retriever_tool missing on_retriever_end Document content (#16933)
- **Description:** In create_retriever_tool create_tool, fix create_retriever_tool's missing Document content for on_retriever_end, caused by create_retriever_tool's missing callbacks parameter, - **Twitter handle:** @CailinWang_ --------- Co-authored-by: root <root@Bluedot-AI> Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
3a22157d92
commit
a210a8bc53
@ -1,6 +1,9 @@
|
||||
from functools import partial
|
||||
from typing import Optional
|
||||
|
||||
from langchain_core.callbacks.manager import (
|
||||
Callbacks,
|
||||
)
|
||||
from langchain_core.prompts import BasePromptTemplate, PromptTemplate, format_document
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
from langchain_core.retrievers import BaseRetriever
|
||||
@ -19,8 +22,9 @@ def _get_relevant_documents(
|
||||
retriever: BaseRetriever,
|
||||
document_prompt: BasePromptTemplate,
|
||||
document_separator: str,
|
||||
callbacks: Callbacks = None,
|
||||
) -> str:
|
||||
docs = retriever.get_relevant_documents(query)
|
||||
docs = retriever.get_relevant_documents(query, callbacks=callbacks)
|
||||
return document_separator.join(
|
||||
format_document(doc, document_prompt) for doc in docs
|
||||
)
|
||||
@ -31,8 +35,9 @@ async def _aget_relevant_documents(
|
||||
retriever: BaseRetriever,
|
||||
document_prompt: BasePromptTemplate,
|
||||
document_separator: str,
|
||||
callbacks: Callbacks = None,
|
||||
) -> str:
|
||||
docs = await retriever.aget_relevant_documents(query)
|
||||
docs = await retriever.aget_relevant_documents(query, callbacks=callbacks)
|
||||
return document_separator.join(
|
||||
format_document(doc, document_prompt) for doc in docs
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user