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

Download files

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

Source Distribution

cohere_compass_sdk-2.16.0.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

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

cohere_compass_sdk-2.16.0-py3-none-any.whl (61.5 kB view details)

Uploaded Python 3

File details

Details for the file cohere_compass_sdk-2.16.0.tar.gz.

File metadata

  • Download URL: cohere_compass_sdk-2.16.0.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.15 Linux/6.17.0-1020-azure

File hashes

Hashes for cohere_compass_sdk-2.16.0.tar.gz
Algorithm Hash digest
SHA256 a98463e5993dc02cf71b959fa807f1c8c91051cbb4c5597cde67ce56ecb6dccd
MD5 cabd5ec8a13f3bb2478bf905655878bb
BLAKE2b-256 6cd844c25df35b98d2a5f9d5ee944d072fc6d8e664a601d249ce8b5ddee6b1ce

See more details on using hashes here.

File details

Details for the file cohere_compass_sdk-2.16.0-py3-none-any.whl.

File metadata

  • Download URL: cohere_compass_sdk-2.16.0-py3-none-any.whl
  • Upload date:
  • Size: 61.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.15 Linux/6.17.0-1020-azure

File hashes

Hashes for cohere_compass_sdk-2.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82502f08ca31661321dbf96e42c443b1996e718325a3f787022c7f667c965808
MD5 86c5146b5c7ef5348fd5ad8eef857b94
BLAKE2b-256 d26625e115cffd02c90e2f8999109820f9155f01e49b3a0f82a52bb8d6c7a81e

See more details on using hashes here.

Release history Release notifications | RSS feed

2.18.0

2 files

2.17.0

2 files

This release

2.16.0 This release

2 files

2.15.1

2 files

2.15.0

2 files

2.14.0

2 files

2.13.0

2 files

2.12.5

2 files

2.12.4

2 files

2.12.3

2 files

2.12.2

2 files

2.12.1

2 files

2.12.0

2 files

2.11.1

2 files

2.11.0

2 files

2.10.0

2 files

2.9.1

2 files

2.9.0

2 files

2.8.1

2 files

2.8.0

2 files

2.7.0

2 files

2.6.1

2 files

2.6.0

2 files

2.5.1

2 files

2.5.0

2 files

2.4.0

2 files

2.3.3

2 files

2.3.2

2 files

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

1.9.0

2 files

1.8.0

2 files

1.7.1

2 files

1.7.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.5

2 files

1.3.3

2 files

1.3.2

2 files

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