-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(example): update jina example to reflect lack of SDK, add cohere …
…example Signed-off-by: Kyle Mistele <[email protected]>
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
Example of using the OpenAI entrypoint's rerank API which is compatible with | ||
the Cohere SDK: https://github.com/cohere-ai/cohere-python | ||
run: vllm serve --model BAAI/bge-reranker-base | ||
""" | ||
import cohere | ||
|
||
# cohere v1 client | ||
co = cohere.Client(base_url="http://localhost:8000", api_key="sk-fake-key") | ||
rerank_v1_result = co.rerank( | ||
model="BAAI/bge-reranker-base", | ||
query="What is the capital of France?", | ||
documents=[ | ||
"The capital of France is Paris", | ||
"Reranking is fun!", | ||
"vLLM is an open-source framework for fast AI serving" | ||
] | ||
) | ||
|
||
print(rerank_v1_result) | ||
|
||
# or the v2 | ||
co2 = cohere.ClientV2("sk-fake-key", base_url="http://localhost:8000") | ||
|
||
v2_rerank_result = co2.rerank( | ||
model="BAAI/bge-reranker-base", | ||
query="What is the capital of France?", | ||
documents=[ | ||
"The capital of France is Paris", | ||
"Reranking is fun!", | ||
"vLLM is an open-source framework for fast AI serving" | ||
] | ||
) | ||
|
||
print(v2_rerank_result) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters