Git Product home page Git Product logo

cohere-python's Introduction

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 the latest features in our API. Please create issues where you have feedback so that we can continue to improve the developer experience!

cohere==5.0.0 Migration Guide

We have created a migration guide to help you through the process. If you have any questions, please feel free to open an issue and we will respond to you asap.

Documentation

Cohere documentation and API reference is available here.

Installation

pip install cohere

Usage

import cohere

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

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

print(chat)

Tip

You can set a system environment variable CO_API_KEY to avoid writing your api key within your code, e.g. add export CO_API_KEY=theapikeyforyouraccount in your ~/.zshrc or ~/.bashrc, open a new terminal, then code calling cohere.Client() will read this key.

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

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!

cohere-python's People

Contributors

mkozakov avatar lfayoux avatar billytrend-cohere avatar fern-api[bot] avatar lusmoura avatar sanderland avatar jimwu6 avatar kipply avatar abdullahkady avatar beatrixcohere avatar 1vn avatar raphael-cohere avatar vshmyhlo avatar choicallum avatar alekhya-n avatar harry-cohere avatar robertkozin avatar aidangomez avatar daniel-cohere avatar alexguo247 avatar innainu avatar amrmkayid avatar alex-matton avatar orenleung avatar raphaelcristal avatar amorisot avatar uday-cohere avatar rodrigue-h avatar mike-meow avatar manoj-cohere avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.