Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "cohere"

[tool.poetry]
name = "cohere"
version = "5.19.0"
version = "5.20.0"
description = ""
readme = "README.md"
authors = []
Expand Down
4 changes: 2 additions & 2 deletions src/cohere/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def __init__(

def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"User-Agent": "cohere/5.19.0",
"User-Agent": "cohere/5.20.0",
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "cohere",
"X-Fern-SDK-Version": "5.19.0",
"X-Fern-SDK-Version": "5.20.0",
}
if self._client_name is not None:
headers["X-Client-Name"] = self._client_name
Expand Down
2 changes: 1 addition & 1 deletion src/cohere/types/chat_finish_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import typing

ChatFinishReason = typing.Union[
typing.Literal["COMPLETE", "STOP_SEQUENCE", "MAX_TOKENS", "TOOL_CALL", "ERROR"], typing.Any
typing.Literal["COMPLETE", "STOP_SEQUENCE", "MAX_TOKENS", "TOOL_CALL", "ERROR", "TIMEOUT"], typing.Any
]
4 changes: 3 additions & 1 deletion src/cohere/types/finish_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import typing

FinishReason = typing.Union[
typing.Literal["COMPLETE", "STOP_SEQUENCE", "ERROR", "ERROR_TOXIC", "ERROR_LIMIT", "USER_CANCEL", "MAX_TOKENS"],
typing.Literal[
"COMPLETE", "STOP_SEQUENCE", "ERROR", "ERROR_TOXIC", "ERROR_LIMIT", "USER_CANCEL", "MAX_TOKENS", "TIMEOUT"
],
typing.Any,
]
48 changes: 48 additions & 0 deletions src/cohere/v2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def chat_stream(
logprobs: typing.Optional[bool] = OMIT,
tool_choice: typing.Optional[V2ChatStreamRequestToolChoice] = OMIT,
thinking: typing.Optional[Thinking] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.Iterator[V2ChatStreamResponse]:
"""
Expand Down Expand Up @@ -158,6 +159,10 @@ def chat_stream(

thinking : typing.Optional[Thinking]

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -205,6 +210,7 @@ def chat_stream(
logprobs=logprobs,
tool_choice=tool_choice,
thinking=thinking,
priority=priority,
request_options=request_options,
) as r:
yield from r.data
Expand All @@ -231,6 +237,7 @@ def chat(
logprobs: typing.Optional[bool] = OMIT,
tool_choice: typing.Optional[V2ChatRequestToolChoice] = OMIT,
thinking: typing.Optional[Thinking] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> V2ChatResponse:
"""
Expand Down Expand Up @@ -323,6 +330,10 @@ def chat(

thinking : typing.Optional[Thinking]

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -368,6 +379,7 @@ def chat(
logprobs=logprobs,
tool_choice=tool_choice,
thinking=thinking,
priority=priority,
request_options=request_options,
)
return _response.data
Expand All @@ -384,6 +396,7 @@ def embed(
output_dimension: typing.Optional[int] = OMIT,
embedding_types: typing.Optional[typing.Sequence[EmbeddingType]] = OMIT,
truncate: typing.Optional[V2EmbedRequestTruncate] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> EmbedByTypeResponse:
"""
Expand Down Expand Up @@ -437,6 +450,10 @@ def embed(

If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -470,6 +487,7 @@ def embed(
output_dimension=output_dimension,
embedding_types=embedding_types,
truncate=truncate,
priority=priority,
request_options=request_options,
)
return _response.data
Expand All @@ -482,6 +500,7 @@ def rerank(
documents: typing.Sequence[str],
top_n: typing.Optional[int] = OMIT,
max_tokens_per_doc: typing.Optional[int] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> V2RerankResponse:
"""
Expand Down Expand Up @@ -509,6 +528,10 @@ def rerank(
max_tokens_per_doc : typing.Optional[int]
Defaults to `4096`. Long documents will be automatically truncated to the specified number of tokens.

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -544,6 +567,7 @@ def rerank(
documents=documents,
top_n=top_n,
max_tokens_per_doc=max_tokens_per_doc,
priority=priority,
request_options=request_options,
)
return _response.data
Expand Down Expand Up @@ -586,6 +610,7 @@ async def chat_stream(
logprobs: typing.Optional[bool] = OMIT,
tool_choice: typing.Optional[V2ChatStreamRequestToolChoice] = OMIT,
thinking: typing.Optional[Thinking] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> typing.AsyncIterator[V2ChatStreamResponse]:
"""
Expand Down Expand Up @@ -678,6 +703,10 @@ async def chat_stream(

thinking : typing.Optional[Thinking]

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -733,6 +762,7 @@ async def main() -> None:
logprobs=logprobs,
tool_choice=tool_choice,
thinking=thinking,
priority=priority,
request_options=request_options,
) as r:
async for _chunk in r.data:
Expand Down Expand Up @@ -760,6 +790,7 @@ async def chat(
logprobs: typing.Optional[bool] = OMIT,
tool_choice: typing.Optional[V2ChatRequestToolChoice] = OMIT,
thinking: typing.Optional[Thinking] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> V2ChatResponse:
"""
Expand Down Expand Up @@ -852,6 +883,10 @@ async def chat(

thinking : typing.Optional[Thinking]

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -905,6 +940,7 @@ async def main() -> None:
logprobs=logprobs,
tool_choice=tool_choice,
thinking=thinking,
priority=priority,
request_options=request_options,
)
return _response.data
Expand All @@ -921,6 +957,7 @@ async def embed(
output_dimension: typing.Optional[int] = OMIT,
embedding_types: typing.Optional[typing.Sequence[EmbeddingType]] = OMIT,
truncate: typing.Optional[V2EmbedRequestTruncate] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> EmbedByTypeResponse:
"""
Expand Down Expand Up @@ -974,6 +1011,10 @@ async def embed(

If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -1015,6 +1056,7 @@ async def main() -> None:
output_dimension=output_dimension,
embedding_types=embedding_types,
truncate=truncate,
priority=priority,
request_options=request_options,
)
return _response.data
Expand All @@ -1027,6 +1069,7 @@ async def rerank(
documents: typing.Sequence[str],
top_n: typing.Optional[int] = OMIT,
max_tokens_per_doc: typing.Optional[int] = OMIT,
priority: typing.Optional[int] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> V2RerankResponse:
"""
Expand Down Expand Up @@ -1054,6 +1097,10 @@ async def rerank(
max_tokens_per_doc : typing.Optional[int]
Defaults to `4096`. Long documents will be automatically truncated to the specified number of tokens.

priority : typing.Optional[int]
The priority of the request (lower means earlier handling; default 0 highest priority).
Higher priority requests are handled first, and dropped last when the system is under load.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -1097,6 +1144,7 @@ async def main() -> None:
documents=documents,
top_n=top_n,
max_tokens_per_doc=max_tokens_per_doc,
priority=priority,
request_options=request_options,
)
return _response.data
Loading