Commit 1ff54bf
authored
refactor: optimize Cohere provider with response pooling and standardized request handling (#724)
## Summary
Refactored the Cohere provider to use a unified request handling approach and improved response object pooling for better performance and memory efficiency.
## Changes
- Implemented `completeRequest` method in Cohere provider to centralize API request handling
- Added object pooling for Cohere embedding responses to reduce memory allocations
- Standardized response handling across all Cohere API endpoints
- Added id, object, and model fields to Chat Completion responses from Bedrock and Cohere providers
- Updated list models functionality to use all available keys
## Type of change
- [ ] Bug fix
- [x] Feature
- [x] Refactor
- [ ] Documentation
- [x] Chore/CI
## Affected areas
- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (Next.js)
- [ ] Docs
## How to test
Test the Cohere provider with various request types to ensure proper functionality:
```sh
# Core/Transports
go version
go test ./...
# Test Cohere provider specifically
go test ./core/providers -run TestCohereProvider
```
## Breaking changes
- [x] No
- [ ] Yes
## Related issues
Improves performance and standardizes response handling across providers.
## Security considerations
No security implications as this is an internal refactoring of existing functionality.
## Checklist
- [x] I added/updated tests where appropriate
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable1 parent 6a929e7 commit 1ff54bf
File tree
9 files changed
+322
-251
lines changed- core
- providers
- schemas/providers
- anthropic
- cohere
- docs/changelogs
- framework
- transports
9 files changed
+322
-251
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments