1414)
1515
1616from deprecation import deprecated as docstring_deprecated
17- from pydantic import AnyHttpUrl , Field , ValidationInfo , field_validator
17+ from pydantic import AnyHttpUrl , AnyUrl , Field , ValidationInfo , field_validator
1818from typing_extensions import TypeAlias
1919from typing_extensions import deprecated as typing_deprecated
2020
@@ -536,6 +536,13 @@ class _RerankerCohereConfig(_RerankerProvider):
536536 default = Rerankers .COHERE , frozen = True , exclude = True
537537 )
538538 model : Optional [Union [RerankerCohereModel , str ]] = Field (default = None )
539+ baseURL : Optional [AnyHttpUrl ]
540+
541+ def _to_dict (self ) -> Dict [str , Any ]:
542+ ret_dict = super ()._to_dict ()
543+ if self .baseURL is not None :
544+ ret_dict ["baseURL" ] = self .baseURL .unicode_string ()
545+ return ret_dict
539546
540547
541548class _RerankerCustomConfig (_RerankerProvider ):
@@ -1259,6 +1266,7 @@ def custom(
12591266 @staticmethod
12601267 def cohere (
12611268 model : Optional [Union [RerankerCohereModel , str ]] = None ,
1269+ base_url : Optional [str ] = None ,
12621270 ) -> _RerankerProvider :
12631271 """Create a `_RerankerCohereConfig` object for use when reranking using the `reranker-cohere` module.
12641272
@@ -1267,8 +1275,11 @@ def cohere(
12671275
12681276 Args:
12691277 model: The model to use. Defaults to `None`, which uses the server-defined default
1278+ base_url: The base URL to send the reranker requests to. Defaults to `None`, which uses the server-defined default.
12701279 """
1271- return _RerankerCohereConfig (model = model )
1280+ return _RerankerCohereConfig (
1281+ model = model , baseURL = AnyUrl (base_url ) if base_url is not None else None
1282+ )
12721283
12731284 @staticmethod
12741285 def jinaai (
0 commit comments