Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 2.03 KB

4.0.0-5.0.0-migration-guide.md

File metadata and controls

62 lines (45 loc) · 2.03 KB

cohere==4 to cohere==5 migration guide

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.

Installation

To install the latest version of the cohere sdk pip3 install --upgrade cohere.

Migrating usages

Migrating function calls

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.

Migrating streaming usage

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='')

Migrating deprecated num_workers Client constructor parameter

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))

Removed functionality (subject to change)

The following lists name the functions that are not in the new SDK and what their ongoing support status is.

No longer supported

  • 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