You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat: Cohere Compass SDK v2.0.0 - Major Release (#149)
### Overview
This PR introduces v2.0.0 of the Cohere Compass SDK, a major release
with significant architectural improvements, new features, and breaking
changes. This branch consolidates all V2 development work into a clean
commit against `main` to avoid merge conflicts.
### 🚀 Major Features
#### 1. **Async/Await Support**
- New `CompassAsyncClient` and `CompassParserAsyncClient` for native
async operations
- Enables better performance for I/O-bound operations
- Supports concurrent request handling with proper async patterns
#### 2. **HTTP Client Migration**
- Migrated from `requests` to `httpx` library
- Benefits: Native async support, HTTP/2 compatibility, better
connection pooling
- Unified sync/async interface
#### 3. **Improved Error Handling**
- Standardized error reporting across the entire SDK
- Better error messages with more context
- Fixed inconsistent behavior between exceptions and error responses
### 🔧 Improvements
- Simplified API URL handling (removed `include_api_in_url` flag)
- General code refactoring and reduced duplication
- Improved type hints using Python 3.11+ native features
### 💥 Breaking Changes
- **Python Version**: Now requires Python 3.11+ (previously 3.9+)
- **Dependencies**:
- Replaced `requests` with `httpx`
- Removed `typing-extensions` (using native Python 3.11+ features)
- Test mocking changed from `requests-mock` to `respx`
### 🧪 Testing
- Updated test suite to use `respx` for httpx mocking
- Added async test support with `pytest-asyncio`
- Maintained comprehensive test coverage
### 📝 Migration Notes
We are planning to write a more detailed Migration Guide for users
upgrading from v1.x to v2.0, but for now the summary is:
1. Ensure Python 3.11+ is installed
2. Update dependencies. If you are using `poetry` or `uv`, you can do a
`poetry|uv sync`
3. Review and update error handling code. Previously, some methods
returned a response with error, and others threw exception. Now, all
methods throw exceptions in case of errors.
4. Some methods might have a slightly different signature. You need to
check the new signature and adjust your call accordingly. Most of the
times, the changes are minimal as the backend of Compass didn't change,
hence the real parameters used in v1.x should still work.
5. Consider adopting async clients for improved performance