From 920280155b2b2edbef34ae4cde65c36898be2dfb Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 17 Sep 2024 23:06:19 -0700 Subject: [PATCH] docs(azure_ai.md): add rerank api endpoint to docs --- docs/my-website/docs/providers/azure_ai.md | 85 ++++++++++++++++++++++ docs/my-website/docs/rerank.md | 3 +- 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/docs/my-website/docs/providers/azure_ai.md b/docs/my-website/docs/providers/azure_ai.md index 23993b52a..60f7ecb2a 100644 --- a/docs/my-website/docs/providers/azure_ai.md +++ b/docs/my-website/docs/providers/azure_ai.md @@ -313,3 +313,88 @@ LiteLLM supports **ALL** azure ai models. Here's a few examples: | AI21-Jamba-Instruct | `completion(model="azure_ai/ai21-jamba-instruct", messages)` | + +## Rerank Endpoint + +### Usage + + + + + + +```python +from litellm import rerank +import os + +os.environ["AZURE_AI_API_KEY"] = "sk-.." +os.environ["AZURE_AI_API_BASE"] = "https://.." + +query = "What is the capital of the United States?" +documents = [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Washington, D.C. is the capital of the United States.", + "Capital punishment has existed in the United States since before it was a country.", +] + +response = rerank( + model="azure_ai/rerank-english-v3.0", + query=query, + documents=documents, + top_n=3, +) +print(response) +``` + + + + +LiteLLM provides an cohere api compatible `/rerank` endpoint for Rerank calls. + +**Setup** + +Add this to your litellm proxy config.yaml + +```yaml +model_list: + - model_name: Salesforce/Llama-Rank-V1 + litellm_params: + model: together_ai/Salesforce/Llama-Rank-V1 + api_key: os.environ/TOGETHERAI_API_KEY + - model_name: rerank-english-v3.0 + litellm_params: + model: azure_ai/rerank-english-v3.0 + api_key: os.environ/AZURE_AI_API_KEY + api_base: os.environ/AZURE_AI_API_BASE +``` + +Start litellm + +```bash +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +Test request + +```bash +curl http://0.0.0.0:4000/rerank \ + -H "Authorization: Bearer sk-1234" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "rerank-english-v3.0", + "query": "What is the capital of the United States?", + "documents": [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Washington, D.C. is the capital of the United States.", + "Capital punishment has existed in the United States since before it was a country." + ], + "top_n": 3 + }' +``` + + + \ No newline at end of file diff --git a/docs/my-website/docs/rerank.md b/docs/my-website/docs/rerank.md index 24033437b..8179e6b81 100644 --- a/docs/my-website/docs/rerank.md +++ b/docs/my-website/docs/rerank.md @@ -112,4 +112,5 @@ curl http://0.0.0.0:4000/rerank \ | Provider | Link to Usage | |-------------|--------------------| | Cohere | [Usage](#quick-start) | -| Together AI| [Usage](../docs/providers/togetherai) | \ No newline at end of file +| Together AI| [Usage](../docs/providers/togetherai) | +| Azure AI| [Usage](../docs/providers/azure_ai) | \ No newline at end of file