Spaces:
Paused
Paused
| from langchain.tools import tool | |
| def get_retrieve_book_context_tool(vector_store): | |
| def retrieve_book_context(query: str) -> str: | |
| """Search the books database for records matching the query. | |
| Args: | |
| query: Search terms to look for | |
| """ | |
| retrieved_docs = vector_store.similarity_search(query, k=4) | |
| serialized = "\n\n".join( | |
| (f"Source: {doc.metadata}\nContent: {doc.page_content}") | |
| for doc in retrieved_docs | |
| ) | |
| return serialized | |
| return retrieve_book_context | |