Skip to main content

No project description provided

Project description

Cohere Python SDK

version badge license badge fern shield

The Cohere Python SDK provides access to the Cohere API from Python.

✨🪩✨ Announcing Cohere's new Python SDK ✨🪩✨

We are very excited to publish this brand new Python SDK. We will continuously update this library with all of the latest features in our API. Please create issues where you have feedback so that we can continue to improve the developer experience!

Documentation

Cohere documentation and API reference is available here.

Installation

pip install --pre --upgrade cohere

Usage

import cohere
from cohere.client import ClassifyExample, ParseInfo

co = cohere.Client(
    api_key="YOUR_API_KEY",
)

chat = co.chat(
    message="hello world!",
    model="command"
)

print(chat)

Streaming

The SDK supports streaming endpoints. To take advantage of this feature for chat, use chat_stream.

import cohere
from cohere.client import ClassifyExample, ParseInfo

co = cohere.Client(
    api_key="YOUR_API_KEY",
)

stream = co.chat_stream(
    message="Tell me a short story"
)

for event in stream:
    if event.event_type == "text-generation":
        print(event.text, end='')

Alpha status

This SDK is in alpha, and while we will try to avoid it, there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your package.json file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributing

While we value open-source contributions to this SDK, the code is generated programmatically. Additions made directly would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cohere-5.0.0a3.tar.gz (49.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cohere-5.0.0a3-py3-none-any.whl (104.7 kB view details)

Uploaded Python 3

File details

Details for the file cohere-5.0.0a3.tar.gz.

File metadata

  • Download URL: cohere-5.0.0a3.tar.gz
  • Upload date:
  • Size: 49.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1054-azure

File hashes

Hashes for cohere-5.0.0a3.tar.gz
Algorithm Hash digest
SHA256 56fcdf0307a1f7514fdeed9a79264899b1a078a1bc2ed1d523bcbac8a605eac0
MD5 58aba809d87edbdaac6b525bbc1ce362
BLAKE2b-256 f199eeeb68d2c2dbd0855411d8b2af57be4fff0f0c51c99ef45d814359437b4f

See more details on using hashes here.

File details

Details for the file cohere-5.0.0a3-py3-none-any.whl.

File metadata

  • Download URL: cohere-5.0.0a3-py3-none-any.whl
  • Upload date:
  • Size: 104.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1054-azure

File hashes

Hashes for cohere-5.0.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 5a96264a0fad3354337dafb895c0d294667e542ff11a2eb528ec5d5dbc5582d6
MD5 1aea6229172e60f128f0d4dc23f2ef8c
BLAKE2b-256 e9b25d06f4377226fe96fe1d43b9bc59c245aaa37bccbaa9f5dfd3a4286c1ed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page