Add product headers to default model providers#118
Add product headers to default model providers#118MohamedSabthar merged 7 commits intoballerina-platform:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdded Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@ballerina/embedding-provider.bal`:
- Around line 90-93: The batchEmbed() call is missing the tracing headers added
in embed(); update batchEmbed() so its call to
self.embeddingClient->/embeddings.post includes the same headers dictionary
("x-product": "bi", "x-usage-context": "model_provider_embeddings") as used in
embed(), ensuring both functions call the same endpoint with identical tracing
headers; locate batchEmbed() and modify the embeddings POST invocation to pass
headers = { "x-product": "bi", "x-usage-context": "model_provider_embeddings" }.
There was a problem hiding this comment.
Pull request overview
This PR adds tracking headers to WSO2 intelligence API calls to identify the product ("bi") and usage context (e.g., "model_provider_chat" or "model_provider_embeddings"). The headers enable better monitoring and analytics for API usage across different contexts.
Changes:
- Added
x-productandx-usage-contextheaders to chat completions API calls in model provider and utility functions - Added the same headers to the embeddings API call in the embedding provider's
embedmethod - Added test assertions to verify the headers are correctly sent with API requests
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ballerina/model-provider.bal | Added tracking headers to chat completions POST request |
| ballerina/embedding-provider.bal | Added tracking headers to embeddings POST request in embed method |
| ballerina/default-model-provider-utils.bal | Added tracking headers to chat completions POST request in utility function |
| ballerina-tests/tests/wso2-model-provider-test-services.bal | Added header parameter extraction and assertions in test service |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (56.06%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #118 +/- ##
============================================
+ Coverage 52.47% 56.06% +3.59%
- Complexity 0 238 +238
============================================
Files 60 80 +20
Lines 4444 5595 +1151
Branches 924 1098 +174
============================================
+ Hits 2332 3137 +805
- Misses 2068 2311 +243
- Partials 44 147 +103 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6dab7a5 to
3d85098
Compare
Purpose
Fixes: wso2/product-ballerina-integrator#2456
Examples
Checklist
Summary
Adds consistent request headers to the default model provider to improve tracing and observability of AI model requests.
Changes
Impact
Enables consistent request-level metadata for model provider interactions to support tracing and monitoring. Existing request construction, response handling, and error flows are unchanged aside from the added headers. Tests were updated to assert presence and expected values of the new headers.