Skip to main content

Test Python Library

Project description

ci badge version badge license badge

Cohere Python SDK

This package provides functionality developed to simplify interfacing with the Cohere API in Python 3.

Documentation

See the API's documentation.

Installation

The package can be installed with pip:

pip install --upgrade cohere

Install from source:

python setup.py install

Requirements

  • Python 3.6+

Quick Start

To use this library, you must have an API key and specify it as a string when creating the cohere.Client object. API keys can be created through the platform. This is a basic example of the creating the client and using the generate endpoint.

import cohere

# initialize the Cohere Client with an API Key
co = cohere.Client('YOUR_API_KEY')

# generate a prediction for a prompt 
prediction = co.generate(
            model='large',
            prompt='co:here',
            max_tokens=10)
            
# print the predicted text          
print('prediction: {}'.format(prediction.generations[0].text))

Versioning

To use the SDK with a specific API version, you can specify it when creating the Cohere Client:

import cohere

co = cohere.Client('YOUR_API_KEY', '2021-11-08')

Endpoints

For a full breakdown of endpoints and arguments, please consult the Cohere Docs.

Cohere Endpoint Function
/generate co.generate()
/choose-best co.choose_best()
/embed co.embed()
/likelihood co.likelihood()

Models

To view an up-to-date list of available models please consult the models section in the platform. To get started try out large for Generate, Choose Best, and Likelihood or small for Embed.

Responses

All of the endpoint functions will return a Cohere object corresponding to the endpoint (e.g. for generation, it would be Generation). The responses can be found as instance variables of the object (e.g. generation would be Generation.text). The names of these instance variables and a detailed breakdown of the response body can be found in the Cohere Docs. Printing the Cohere response object itself will display an organized view of the instance variables.

Exceptions

Unsuccessful API calls from the SDK will raise an exception. Please see the documentation's page on errors for more information about what the errors mean.

Project details


Download files

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

Source Distribution

testpythonalex-1.0.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

testpythonalex-1.0.3-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file testpythonalex-1.0.3.tar.gz.

File metadata

  • Download URL: testpythonalex-1.0.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for testpythonalex-1.0.3.tar.gz
Algorithm Hash digest
SHA256 ac4c1d71505d36795e00401c2bbb482caa2f991d06b5e67de03f792ea081c14d
MD5 bda4d5873c85e323de2d9cdb1a19c34e
BLAKE2b-256 1dd26a2351fa6e44f06c33462c8dfe73d2e840281a6bba6238356fbe7439018a

See more details on using hashes here.

File details

Details for the file testpythonalex-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: testpythonalex-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for testpythonalex-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 55467b1d327d97ccd478f8729a05ac3ddcfb9b622401623ab12d64c1dec130f0
MD5 55c2c13cd3ad5a1b7726b20c4cdbd86f
BLAKE2b-256 a567d161985b551df6f3f96048894e344f665d6d4f291e4f37ac968cd2e82adb

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