Skip to content

Commit ffe766f

Browse files
mginfnMauro Gattari
andauthored
chore: added base_url parameter to CochereReranking (#743)
Co-authored-by: Mauro Gattari <[email protected]>
1 parent 833982a commit ffe766f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libs/kotaemon/kotaemon/rerankings/cohere.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
from decouple import config
45

56
from kotaemon.base import Document, Param
@@ -23,6 +24,9 @@ class CohereReranking(BaseReranking):
2324
help="Cohere API key",
2425
required=True,
2526
)
27+
base_url: str = Param(
28+
None, help="Rerank API base url. Default is https://api.cohere.com", required=False
29+
)
2630

2731
def run(self, documents: list[Document], query: str) -> list[Document]:
2832
"""Use Cohere Reranker model to re-order documents
@@ -38,7 +42,7 @@ def run(self, documents: list[Document], query: str) -> list[Document]:
3842
print("Cohere API key not found. Skipping rerankings.")
3943
return documents
4044

41-
cohere_client = cohere.Client(self.cohere_api_key)
45+
cohere_client = cohere.Client(self.cohere_api_key, base_url=self.base_url or os.getenv("CO_API_URL"))
4246
compressed_docs: list[Document] = []
4347

4448
if not documents: # to avoid empty api call

0 commit comments

Comments
 (0)