Skip to main content

Cohere Compass SDK

Checked with pyright

The Compass SDK is a Python library that allows you to parse documents and insert them into a Compass index.

In order to parse documents, the Compass SDK relies on the Compass Parser API, which is a RESTful API that receives files and returns parsed documents. This requires a hosted Compass server.

The Compass SDK provides a CompassParserClient that allows to interact with the parser API from your Python code in a convenient manner. The CompassParserClient provides methods to parse single and multiple files, as well as entire folders, and supports multiple file types (e.g., pdf, docx, json, csv, etc.) as well as different file systems (e.g., local, S3, GCS, etc.).

To insert parsed documents into a Compass index, the Compass SDK provides a CompassClient class that allows to interact with a Compass API server. The Compass API is also a RESTful API that allows to create, delete and search documents in a Compass index.

Table of Contents

Getting Started

Installation

To install the SDK using pip:

pip install cohere-compass-sdk

If you are using a package management tool like poetry or uv:

poetry add cohere-compass-sdk

or

uv add cohere-compass-sdk

Once you install it, the best way to learn how to use the SDK is to head over to our examples. For the API reference, you can visit this link.

V2 Migration Guide

To improve the quality of the SDK and address multiple long-standing issues, as well as supporting async clients, we decided to introduce v2.0, a new major version. v2.0 has breaking changes and will require code changes. Fortunately, the changes are minimal and can frequently be deduced just by looking at the new signatures of the APIs. Below is a summary:

  • Previously, we had multiple methods that relied on return values for error handling. This is no more the case, and almost all methods now raise exceptions in case of errors. This means that instead of a code like:
result = compass_client.create_index(...)
if result.error:
    # do something about the error

you instead do:

try:
    result = compass_client.create_index(...)
except:
    # do something about the error
  • v2.0 supports async clients. Async clients maintain the same signature as their sync counterparts. So, where you would do the following to create an index:
client = CompassClient(index_url=api_url, bearer_token=bearer_token)
client.create_index(...)

In async, you simply do:

client = CompassAsyncClient(index_url=api_url, bearer_token=bearer_token)
await client.create_index(...)

Local Development

Create Python Virtual Environment

We use Poetry to manage our Python environment. To create the virtual environment use the following command:

poetry sync

Running Tests Locally

We use pytest for testing. So, you can simply run tests using the following command:

poetry run python -m pytest

VSCode Users

We provide .vscode folder for those developers who prefer to use VSCode. You just need to open the folder in VSCode and VSCode should pick our settings.

Pre-commit

We love and appreciate Coding Standards and so we enforce them in our code base. However, without automation, enforcing Coding Standards usually result in a lot of frustration for developers when they publish Pull Requests and our linters complain. So, we automate our formatting and linting with pre-commit. All you need to do is install our pre-commit hook so the code gets formatted automatically when you commit your changes locally:

poetry run pre-commit install

Metadata

Release files for cohere-compass-sdk 2.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cohere-compass-sdk 2.20.0
File Size Uploaded Provenance Actions
cohere_compass_sdk-2.20.0.tar.gz 54.3 kB Without provenance Details for cohere_compass_sdk-2.20.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cohere-compass-sdk 2.20.0
File Interpreter ABI Platform Actions
cohere_compass_sdk-2.20.0-py3-none-any.whl Python 3 none any Details for cohere_compass_sdk-2.20.0-py3-none-any.whl

Total release size: 119.0 kB

Release files / cohere_compass_sdk-2.20.0.tar.gz

Download URL cohere_compass_sdk-2.20.0.tar.gz
Size 54.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2eda4d49b2cfa5c4df839b3025ac0e5b846e3c716a1bbf6292240fc8e3850327
BLAKE2b-256 checksum
How to use checksums
52f4891ebd4d174da8b5253559a9d8339a9da7e8d5eee200841f3530c394464b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.16 Linux/6.17.0-1022-azure

Release files / cohere_compass_sdk-2.20.0-py3-none-any.whl

Download URL cohere_compass_sdk-2.20.0-py3-none-any.whl
Size 64.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9dade80cc1e1f76068462e92865a7b66ce19f7fd4b1d157c619a596198aece5
BLAKE2b-256 checksum
How to use checksums
c7f1994739adc1dc8a82d391fdc45dd06b5128e462c35f20b5c4dfa11918bcba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.16 Linux/6.17.0-1022-azure

Security for cohere-compass-sdk 2.20.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.20.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page