Open tyu008 opened 5 months ago
Now I have a series of two function calls.
(1) ranked_docs_1 = ranker.compress_documents(query=query1, documents=docs)
(2) ranked_docs_2 = ranker.compress_documents(query=query2, documents=docs)
The second call (2), will influence the content in ranked_docs_1. It brings me an issue when using it.
A workaround solution is to use deep copy in the input, e.g. ranker.compress_documents(query=query, documents=copy.deepcopy(docs))
Could we implement the deep-copy within the function "ranker.compress_documents"?
Below the testing codes leading to the above issues.
`from langchain.docstore.document import Document from langchain_nvidia_ai_endpoints import NVIDIARerank import os os.environ["NVIDIA_API_KEY"]=""
ranker = NVIDIARerank() docs = [] queries = [] for i in range(10): docs.append(Document(page_content=str(i))) queries.append(str(i) + "test") IRs = [] for idx, query in enumerate(queries): IRs.append( ranker.compress_documents(query=query, documents=docs) ) print(str(IRs[0]))`
Now I have a series of two function calls.
(1) ranked_docs_1 = ranker.compress_documents(query=query1, documents=docs)
(2) ranked_docs_2 = ranker.compress_documents(query=query2, documents=docs)
The second call (2), will influence the content in ranked_docs_1. It brings me an issue when using it.
A workaround solution is to use deep copy in the input, e.g. ranker.compress_documents(query=query, documents=copy.deepcopy(docs))
Could we implement the deep-copy within the function "ranker.compress_documents"?
Below the testing codes leading to the above issues.
`from langchain.docstore.document import Document from langchain_nvidia_ai_endpoints import NVIDIARerank import os os.environ["NVIDIA_API_KEY"]=""
ranker = NVIDIARerank() docs = [] queries = [] for i in range(10): docs.append(Document(page_content=str(i))) queries.append(str(i) + "test") IRs = [] for idx, query in enumerate(queries): IRs.append( ranker.compress_documents(query=query, documents=docs) ) print(str(IRs[0]))`