This PR introduces a new V2 API for the Cohere client. It adds support for a new chat_stream method, which allows for a streamed chat experience with the ability to send and receive messages in real time.
The new V2 API also includes a chat method, which is a non-streamed version of chat_stream.
The following changes have been made:
Added a new v2 module with the ClientV2 and AsyncClientV2 classes.
Updated the Client and AsyncClient classes to include a reference to the new V2Client and AsyncV2Client classes, respectively.
Added new classes and enums to the cohere/v2/types module to support the new API.
Updated the ClientEnvironment enum to remove the /v1 endpoint.
Updated the BaseCohere class to include a fix_base_url method, which removes /v1 from the base URL if present.
Updated the chat_stream and chat methods in the BaseCohere class to use the new V2 API endpoint (`/v2/chat).
Updated the chat_stream and chat methods in the BaseCohere class to include new parameters specific to the V2 API.
Updated the chat_stream method in the BaseCohere class to return an iterator of StreamedChatResponse2 objects.
Updated the chat method in the BaseCohere class to return a NonStreamedChatResponse2 object.
Updated the chat_stream and chat methods in the BaseCohere class to include error handling for the new error types introduced in the V2 API.
This PR introduces a new V2 API for the Cohere client. It adds support for a new
chat_stream
method, which allows for a streamed chat experience with the ability to send and receive messages in real time.The new V2 API also includes a
chat
method, which is a non-streamed version ofchat_stream
.The following changes have been made:
v2
module with theClientV2
andAsyncClientV2
classes.Client
andAsyncClient
classes to include a reference to the newV2Client
andAsyncV2Client
classes, respectively.cohere/v2/types
module to support the new API./v1
endpoint.fix_base_url
method, which removes/v1
from the base URL if present.StreamedChatResponse2
objects.NonStreamedChatResponse2
object.