As we migrate from the handwritten, manually-maintained sdk to our auto-generated sdk, there are some breaking changes that must be accommodated during migration. These should mostly improve the developer experience but thank you for bearing with us as we make these changes.
To install the latest version of the cohere sdk pip3 install --upgrade cohere
.
This diff view enumerates all usages of the old sdk and how they map to the new sdk. Some fields are no longer supported in the new sdk.
The streaming: boolean
are no longer supported in the new sdk. Instead, you can replace the chat
function with chat_stream
and generate
function with generate_stream
. These will automatically inject the streaming
parameter into the request. The following is an example usage for chat_stream
:
stream = co.chat_stream(
message="Tell me a short story"
)
for event in stream:
if event.event_type == "text-generation":
print(event.text, end='')
The Client constructor accepts an httpx_client
which can be configured to limit the maximum number of connections.
limits = httpx.Limits(max_connections=10)
cohere.Client(httpx_client=httpx.Client(limits=limits))
The following lists name the functions that are not in the new SDK and what their ongoing support status is.
- check_api_key
- loglikelihood
- batch_generate
- codebook
- batch_tokenize
- batch_detokenize
- detect_language
- generate_feedback
- generate_preference_feedback
- create_cluster_job
- get_cluster_job
- list_cluster_jobs
- wait_for_cluster_job
- create_custom_model
- wait_for_custom_model
- get_custom_model
- get_custom_model_by_name
- get_custom_model_metrics
- list_custom_models