Skip to content

Commit a38060f

Browse files
committed
doc(example): update jina example to reflect lack of SDK, add cohere example
Signed-off-by: Kyle Mistele <[email protected]>
1 parent cce2873 commit a38060f

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Example of using the OpenAI entrypoint's rerank API which is compatible with
3+
the Cohere SDK: https://github.com/cohere-ai/cohere-python
4+
5+
run: vllm serve --model BAAI/bge-reranker-base
6+
"""
7+
import cohere
8+
9+
# cohere v1 client
10+
co = cohere.Client(base_url="http://localhost:8000", api_key="sk-fake-key")
11+
rerank_v1_result = co.rerank(
12+
model="BAAI/bge-reranker-base",
13+
query="What is the capital of France?",
14+
documents=[
15+
"The capital of France is Paris",
16+
"Reranking is fun!",
17+
"vLLM is an open-source framework for fast AI serving"
18+
]
19+
)
20+
21+
print(rerank_v1_result)
22+
23+
# or the v2
24+
co2 = cohere.ClientV2("sk-fake-key", base_url="http://localhost:8000")
25+
26+
v2_rerank_result = co2.rerank(
27+
model="BAAI/bge-reranker-base",
28+
query="What is the capital of France?",
29+
documents=[
30+
"The capital of France is Paris",
31+
"Reranking is fun!",
32+
"vLLM is an open-source framework for fast AI serving"
33+
]
34+
)
35+
36+
print(v2_rerank_result)
37+

examples/online_serving/jinjaai_rerank_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Example of using the OpenAI entrypoint's rerank API which is compatible with
3-
Jina and Cohere
3+
Jina and Cohere https://jina.ai/reranker
4+
45
run: vllm serve --model BAAI/bge-reranker-base
56
"""
67
import json
@@ -21,7 +22,6 @@
2122
"The capital of France is Paris.", "Horses and cows are both animals"
2223
]
2324
}
24-
2525
response = requests.post(url, headers=headers, json=data)
2626

2727
# Check the response

0 commit comments

Comments
 (0)