Skip to content

Add text and image document support for Ballerina OpenAI model provider#18

Merged
SasinduDilshara merged 22 commits intoballerina-platform:mainfrom
SasinduDilshara:add-image-documents
Jul 26, 2025
Merged

Add text and image document support for Ballerina OpenAI model provider#18
SasinduDilshara merged 22 commits intoballerina-platform:mainfrom
SasinduDilshara:add-image-documents

Conversation

@SasinduDilshara
Copy link
Contributor

Add text and image document support for Ballerina OpenAI model provider

Related to ballerina-platform/ballerina-library#7868

@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

❌ Patch coverage is 94.23077% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.74%. Comparing base (91ec4ea) to head (03c7523).
⚠️ Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
ballerina/provider_utils.bal 94.23% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
+ Coverage   30.46%   35.74%   +5.27%     
==========================================
  Files           5        5              
  Lines         407      442      +35     
  Branches      100      112      +12     
==========================================
+ Hits          124      158      +34     
- Misses        283      284       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SasinduDilshara SasinduDilshara requested a review from Copilot July 26, 2025 04:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for text and image documents in the Ballerina OpenAI model provider, enabling multimodal AI interactions. It refactors the prompt processing to use structured content parts instead of simple strings and adds comprehensive test coverage for the new document types.

  • Adds support for ai:ImageDocument and ai:ImageDocument[] types with binary data and URL content
  • Implements validation for image URLs and proper base64 encoding for binary image data
  • Refactors prompt processing from string concatenation to structured content parts array

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ballerina/types.bal Adds new GPT model variant for audio preview support
ballerina/provider_utils.bal Core implementation of document processing with image support and URL validation
ballerina/tests/tests.bal Comprehensive test suite for image document functionality and error handling
ballerina/tests/test_values.bal Test data and expected content parts for multimodal document tests
ballerina/tests/test_utils.bal Updated mock response handlers to support new document content structure
ballerina/tests/test_services.bal Modified test service to handle structured content parts instead of strings
ballerina/Dependencies.toml Updated dependencies for constraint validation and array utilities

} else if doc is ai:ImageDocument {
return contentParts.push(check buildImageContentPart(doc));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

if content.length() == 0 {
return;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Member

@MohamedSabthar MohamedSabthar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added minor comments

@SasinduDilshara
Copy link
Contributor Author

Will fix the comments with the next PR(PR for labels)

@SasinduDilshara SasinduDilshara merged commit 4c50f63 into ballerina-platform:main Jul 26, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants