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.

5.0.0 alpha 🚀

We will release our brand new cohere-python SDK on the 18th of March 2024! If you'd like to get a head start by installing the alpha version, please go ahead and use pip install --pre --upgrade cohere. Thanks for your patience as we make breaking changes where necessary. If you have any issues using it, we will respond to github issues as soon as possible.

Documentation

Cohere documentation and API reference is available here.

Installation

pip install --pre --upgrade cohere

Usage

import cohere

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

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.0a12.tar.gz (60.5 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.0a12-py3-none-any.whl (123.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cohere-5.0.0a12.tar.gz
  • Upload date:
  • Size: 60.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1058-azure

File hashes

Hashes for cohere-5.0.0a12.tar.gz
Algorithm Hash digest
SHA256 23d22d047f3f1cb924be7f44ef868aa629abb8efdec478ffcaf83f1af8d0f6ec
MD5 79174ed58aee3ef5746022914cc51a6b
BLAKE2b-256 6ae3fb4e3a240048c6e195f143b06e397310419feaae8a7da26e135da1bbaab9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cohere-5.0.0a12-py3-none-any.whl
Algorithm Hash digest
SHA256 1e577f6a889984c52cb8e74b4965d2c092cea45979f03ee96cd98db1116fa31f
MD5 f124b6f6407666b29b47e6ee14ffb006
BLAKE2b-256 447ed09c5b0f1239550d6520e42c23fd651d69fda3ec9c50ac0280cbccee67ba

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