mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
fix(huggingface): stop forcing truncate=false on TEI rerank and pass truncate params through
Co-authored-by: Luke Schaefer <225965040+luke-e-schaefer@users.noreply.github.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
3c7532da64
commit
6047649b69
2 changed files with 8 additions and 1 deletions
|
|
@ -78,6 +78,8 @@ class HuggingFaceRerankConfig(BaseRerankConfig):
|
|||
"documents",
|
||||
"top_n",
|
||||
"return_documents",
|
||||
"truncate",
|
||||
"truncation_direction",
|
||||
]
|
||||
|
||||
def map_cohere_rerank_params(
|
||||
|
|
@ -104,6 +106,10 @@ class HuggingFaceRerankConfig(BaseRerankConfig):
|
|||
optional_rerank_params["return_text"] = v
|
||||
elif k == "top_n" and v is not None:
|
||||
optional_rerank_params["top_n"] = v
|
||||
elif k == "truncate" and isinstance(v, bool):
|
||||
optional_rerank_params["truncate"] = v
|
||||
elif k == "truncation_direction" and v is not None:
|
||||
optional_rerank_params["truncation_direction"] = v
|
||||
elif k == "documents" and v is not None:
|
||||
optional_rerank_params["texts"] = v
|
||||
elif k == "query" and v is not None:
|
||||
|
|
@ -151,7 +157,6 @@ class HuggingFaceRerankConfig(BaseRerankConfig):
|
|||
# HuggingFace API expects return_text parameter, corresponding to our return_documents parameter
|
||||
request_body: Final = {
|
||||
"raw_scores": False,
|
||||
"truncate": False,
|
||||
"truncation_direction": "Right",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ class OptionalRerankParams(TypedDict, total=False):
|
|||
max_chunks_per_doc: int | None
|
||||
max_tokens_per_doc: int | None
|
||||
instruction: str | None
|
||||
truncate: ReadOnly[bool]
|
||||
truncation_direction: ReadOnly[str | None]
|
||||
truncate_prompt_tokens: ReadOnly[int | None]
|
||||
truncation_side: ReadOnly[Literal["left", "right"] | None]
|
||||
max_tokens_per_query: ReadOnly[int | None]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue