Name | cohere JSON |
Version |
5.13.4
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-12-20 11:59:20 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4.0,>=3.9 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Cohere Python SDK
![](banner.png)
[![version badge](https://img.shields.io/pypi/v/cohere)](https://pypi.org/project/cohere/)
![license badge](https://img.shields.io/github/license/cohere-ai/cohere-python)
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)
The Cohere Python SDK allows access to Cohere models across many different platforms: the cohere platform, AWS (Bedrock, Sagemaker), Azure, GCP and Oracle OCI. For a full list of support and snippets, please take a look at the [SDK support docs page](https://docs.cohere.com/docs/cohere-works-everywhere).
## Documentation
Cohere documentation and API reference is available [here](https://docs.cohere.com/).
## Installation
```
pip install cohere
```
## Usage
```Python
import cohere
co = cohere.ClientV2()
response = co.chat(
model="command-r-plus-08-2024",
messages=[{"role": "user", "content": "hello world!"}],
)
print(response)
```
> [!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`.
```Python
import cohere
co = cohere.ClientV2()
response = co.chat_stream(
model="command-r-plus-08-2024",
messages=[{"role": "user", "content": "hello world!"}],
)
for event in response:
if event.type == "content-delta":
print(event.delta.message.content.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!
Raw data
{
"_id": null,
"home_page": null,
"name": "cohere",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/25/86/478db08631fa6d8102c0632da33f54119eeeaa28d1a74c133666e828b359/cohere-5.13.4.tar.gz",
"platform": null,
"description": "# Cohere Python SDK\n\n![](banner.png)\n\n[![version badge](https://img.shields.io/pypi/v/cohere)](https://pypi.org/project/cohere/)\n![license badge](https://img.shields.io/github/license/cohere-ai/cohere-python)\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)\n\nThe Cohere Python SDK allows access to Cohere models across many different platforms: the cohere platform, AWS (Bedrock, Sagemaker), Azure, GCP and Oracle OCI. For a full list of support and snippets, please take a look at the [SDK support docs page](https://docs.cohere.com/docs/cohere-works-everywhere).\n\n## Documentation\n\nCohere documentation and API reference is available [here](https://docs.cohere.com/).\n\n## Installation\n\n```\npip install cohere\n```\n\n## Usage\n\n```Python\nimport cohere\n\nco = cohere.ClientV2()\n\nresponse = co.chat(\n model=\"command-r-plus-08-2024\",\n messages=[{\"role\": \"user\", \"content\": \"hello world!\"}],\n)\n\nprint(response)\n```\n\n> [!TIP]\n> 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`\n> in your ~/.zshrc or ~/.bashrc, open a new terminal, then code calling `cohere.Client()` will read this key.\n\n\n## Streaming\n\nThe SDK supports streaming endpoints. To take advantage of this feature for chat,\nuse `chat_stream`.\n\n```Python\nimport cohere\n\nco = cohere.ClientV2()\n\nresponse = co.chat_stream(\n model=\"command-r-plus-08-2024\",\n messages=[{\"role\": \"user\", \"content\": \"hello world!\"}],\n)\n\nfor event in response:\n if event.type == \"content-delta\":\n print(event.delta.message.content.text, end=\"\")\n```\n\n## Contributing\n\nWhile 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!\n\nOn the other hand, contributions to the README are always very welcome!\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "5.13.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9af1156517e1aea101f2195161786cc9625a7305798e55565f66a85df964d031",
"md5": "c4ff0eee5cc3e051ce9947ca63753b18",
"sha256": "f3d81cef93ded8ea57dde6d4a547598846c9e836c18834fe0c6d2bb3da1d8e8f"
},
"downloads": -1,
"filename": "cohere-5.13.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c4ff0eee5cc3e051ce9947ca63753b18",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 250017,
"upload_time": "2024-12-20T11:59:18",
"upload_time_iso_8601": "2024-12-20T11:59:18.168253Z",
"url": "https://files.pythonhosted.org/packages/9a/f1/156517e1aea101f2195161786cc9625a7305798e55565f66a85df964d031/cohere-5.13.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2586478db08631fa6d8102c0632da33f54119eeeaa28d1a74c133666e828b359",
"md5": "556a125d3d12bfac8fc5f33d807dbf15",
"sha256": "ade5e817368a73dbdaa2bf5a812ad0952d59bdf3e583928e5207774b964d7d6b"
},
"downloads": -1,
"filename": "cohere-5.13.4.tar.gz",
"has_sig": false,
"md5_digest": "556a125d3d12bfac8fc5f33d807dbf15",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 130511,
"upload_time": "2024-12-20T11:59:20",
"upload_time_iso_8601": "2024-12-20T11:59:20.905608Z",
"url": "https://files.pythonhosted.org/packages/25/86/478db08631fa6d8102c0632da33f54119eeeaa28d1a74c133666e828b359/cohere-5.13.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-20 11:59:20",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "cohere"
}