You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched existing ideas and did not find a similar one
I added a very descriptive title
I've clearly described the feature request and motivation for it
Feature request
I recently used CohereRerank and found that it cannot track detailed input and output content on LangSmith.
And CohereRerank lacks a score_threshold filtering parameter similar to the one in retrievers (currently it only has top_n).
Motivation
Make objects like CohereRerank that inherit from BaseDocumentCompressor traceable and callable using invoke.
Proposal (If applicable)
I studied the source code and found that its parent class, BaseDocumentCompressor, is not a Runnable but simply a BaseModel.
Since BaseDocumentCompressor already has an abstract method compress_documents, and there is a lot of existing code that inherits from this class, I've thought of a simple solution:
Change BaseDocumentCompressor to inherit from RunnableLambda instead of BaseModel.
Then, let invoke directly execute compress_documents.
Or execute super().__init__ in the __init__ method and pass the compress_documents function to it.
In the current ContextualCompressionRetriever(which is a BaseRetriever), change the compress_documents method to invoke.
This way, the original method remains intact (you can still use compress_documents), while allowing ContextualCompressionRetriever to track content.
Additionally, BaseDocumentCompressor can directly use invoke.
If the above modification is acceptable, I can implement this feature and submit a PR.
Please let me know everyone's thoughts on this feature.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
I recently used
CohereRerank
and found that it cannot track detailed input and output content onLangSmith
.And
CohereRerank
lacks ascore_threshold
filtering parameter similar to the one in retrievers (currently it only hastop_n
).Motivation
Make objects like
CohereRerank
that inherit fromBaseDocumentCompressor
traceable and callable usinginvoke
.Proposal (If applicable)
I studied the source code and found that its parent class,
BaseDocumentCompressor
, is not aRunnable
but simply aBaseModel
.Since
BaseDocumentCompressor
already has an abstract methodcompress_documents
, and there is a lot of existing code that inherits from this class, I've thought of a simple solution:Change
BaseDocumentCompressor
to inherit fromRunnableLambda
instead ofBaseModel
.Then, let
invoke
directly executecompress_documents
.Or execute
super().__init__
in the__init__
method and pass thecompress_documents
function to it.In the current
ContextualCompressionRetriever
(which is aBaseRetriever
), change thecompress_documents
method toinvoke
.This way, the original method remains intact (you can still use
compress_documents
), while allowingContextualCompressionRetriever
to track content.Additionally,
BaseDocumentCompressor
can directlyuse invoke
.If the above modification is acceptable, I can implement this feature and submit a PR.
Please let me know everyone's thoughts on this feature.
Beta Was this translation helpful? Give feedback.
All reactions