Skip to content

Comments

Add knowledgebase implementation for Ai Azure#24

Merged
SasinduDilshara merged 10 commits intoballerina-platform:mainfrom
SasinduDilshara:add-azure-knowledgebase
Oct 23, 2025
Merged

Add knowledgebase implementation for Ai Azure#24
SasinduDilshara merged 10 commits intoballerina-platform:mainfrom
SasinduDilshara:add-azure-knowledgebase

Conversation

@SasinduDilshara
Copy link
Contributor

@SasinduDilshara SasinduDilshara commented Oct 23, 2025

Add knowledgebase implementation for Ai Azure

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 0% with 388 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.76%. Comparing base (c038c46) to head (ccf8150).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
ballerina/azure_ai_search_knowledgebase.bal 0.00% 388 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #24       +/-   ##
===========================================
- Coverage   60.74%   28.76%   -31.98%     
===========================================
  Files           4        5        +1     
  Lines         349      737      +388     
  Branches      103      223      +120     
===========================================
  Hits          212      212               
- Misses        137      525      +388     

☔ 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.

MohamedSabthar
MohamedSabthar previously approved these changes Oct 23, 2025
Copy link
Member

@MaryamZi MaryamZi left a comment

Choose a reason for hiding this comment

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

Given the urgency, we can focus on the comments that have an impact on the public APIs for now.

# + maxLimit - The maximum number of items to return
# + filters - Optional metadata filters to apply during retrieval
# + return - An array of matching chunks with similarity scores, or an `ai:Error` if retrieval fails
public isolated function retrieve(string query, int maxLimit = 10, ai:MetadataFilters? filters = ()) returns ai:QueryMatch[]|ai:Error {
Copy link
Member

Choose a reason for hiding this comment

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

Methods generally seem to be long. Unless not possible because of isolated, would be better to break up into functions. Will also get simplified with things like query expressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do in another PR

}

private isolated function buildODataFilter(ai:MetadataFilters filters) returns string? {
return self.convertFiltersToOData(filters);
Copy link
Member

Choose a reason for hiding this comment

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

Why not call this directly?

Copy link
Contributor Author

@SasinduDilshara SasinduDilshara Oct 23, 2025

Choose a reason for hiding this comment

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

We can use both approaches I guess

Copy link
Member

Choose a reason for hiding this comment

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

Why this though? It's just another level of indirection in the current state.

@SasinduDilshara SasinduDilshara merged commit d7a2689 into ballerina-platform:main Oct 23, 2025
2 of 4 checks passed
Copy link
Member

@MaryamZi MaryamZi left a comment

Choose a reason for hiding this comment

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

@SasinduDilshara is there an issue tracking adding tests? Please create an issue to track addressing the suggestions also.

}

private isolated function buildODataFilter(ai:MetadataFilters filters) returns string? {
return self.convertFiltersToOData(filters);
Copy link
Member

Choose a reason for hiding this comment

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

Why this though? It's just another level of indirection in the current state.

Comment on lines +400 to +404
if filterExpressions.length() == 0 {
return ();
}

if filterExpressions.length() == 1 {
Copy link
Member

Choose a reason for hiding this comment

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

filterExpressions.length() accessed repeatedly.

conditions.push(string `${fieldName} ${ODATA_OPERATOR_EQ} ${formattedValue}`);
}
}
if conditions.length() > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Not necessary.

Comment on lines +484 to +497
index:IndexAction|ai:Error indexAction = createIndexAction(
doc,
embedding,
i,
self.keyFieldName,
self.contentFieldName,
self.vectorFieldNames,
self.allFields,
self.verbose
);

if indexAction is ai:Error {
return indexAction;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why aren't you using check instead?

Comment on lines +785 to +787
} else {
if isPossibleMetadata {
logIfVerboseEnabled(
Copy link
Member

Choose a reason for hiding this comment

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

Can be an else-if.

Can do an early return (continue) above too.

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.

4 participants