100 lines
3.4 KiB
Plaintext
100 lines
3.4 KiB
Plaintext
Metadata-Version: 2.1
|
|
Name: cohere
|
|
Version: 5.15.0
|
|
Summary:
|
|
License: MIT
|
|
Requires-Python: >=3.9,<4.0
|
|
Classifier: Intended Audience :: Developers
|
|
Classifier: License :: OSI Approved :: MIT License
|
|
Classifier: Operating System :: MacOS
|
|
Classifier: Operating System :: Microsoft :: Windows
|
|
Classifier: Operating System :: OS Independent
|
|
Classifier: Operating System :: POSIX
|
|
Classifier: Operating System :: POSIX :: Linux
|
|
Classifier: Programming Language :: Python
|
|
Classifier: Programming Language :: Python :: 3
|
|
Classifier: Programming Language :: Python :: 3.9
|
|
Classifier: Programming Language :: Python :: 3.10
|
|
Classifier: Programming Language :: Python :: 3.11
|
|
Classifier: Programming Language :: Python :: 3.12
|
|
Classifier: Programming Language :: Python :: 3.8
|
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
Classifier: Typing :: Typed
|
|
Requires-Dist: fastavro (>=1.9.4,<2.0.0)
|
|
Requires-Dist: httpx (>=0.21.2)
|
|
Requires-Dist: httpx-sse (==0.4.0)
|
|
Requires-Dist: pydantic (>=1.9.2)
|
|
Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
|
|
Requires-Dist: requests (>=2.0.0,<3.0.0)
|
|
Requires-Dist: tokenizers (>=0.15,<1)
|
|
Requires-Dist: types-requests (>=2.0.0,<3.0.0)
|
|
Requires-Dist: typing_extensions (>=4.0.0)
|
|
Description-Content-Type: text/markdown
|
|
|
|
# Cohere Python SDK
|
|
|
|

|
|
|
|
[](https://pypi.org/project/cohere/)
|
|

|
|
[](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!
|
|
|