community: FlashrankRerank support loading customer client (#23350)

Description: FlashrankRerank Document compressor support loading
customer client
Issue: #23338

Co-authored-by: gongwn1 <gongwn1@lenovo.com>
This commit is contained in:
wenngong 2024-06-25 05:50:08 +08:00 committed by GitHub
parent f58c40b4e3
commit b33d2346db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,6 +38,9 @@ class FlashrankRerank(BaseDocumentCompressor):
@root_validator(pre=True)
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api key and python package exists in environment."""
if "client" in values:
return values
else:
try:
from flashrank import Ranker
except ImportError: