add basic cohere rerank

This commit is contained in:
Ishaan Jaff 2024-08-27 15:55:43 -07:00
parent 6ab8cbc105
commit 3a82334762
2 changed files with 21 additions and 0 deletions

View file

@ -934,6 +934,7 @@ from .proxy.proxy_cli import run_server
from .router import Router
from .assistants.main import *
from .batches.main import *
from .rerank_api.main import *
from .fine_tuning.main import *
from .files.main import *
from .scheduler import *

View file

@ -0,0 +1,20 @@
"""
LiteLLM Follows the cohere API format for the re rank API
https://docs.cohere.com/reference/rerank
"""
from pydantic import BaseModel
class RerankRequest(BaseModel):
model: str
query: str
top_n: int
documents: list[str]
class RerankResponse(BaseModel):
id: str
results: list[dict] # Contains index and relevance_score
meta: dict # Contains api_version and billed_units