-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Orchestration Grounding convenience #293
Conversation
@Accessors(fluent = true) | ||
public class Grounding implements GroundingProvider { | ||
|
||
private String id = "someID"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Major)
Please make this a required argument. I doubt we can use someID
globally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be useless, I set it to empty string
orchestration/src/main/java/com/sap/ai/sdk/orchestration/GroundingProvider.java
Show resolved
Hide resolved
// optional filter for document chunks | ||
var databaseFilter = | ||
DocumentGroundingFilter.create() | ||
.id("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Minor/Comment)
According to spec this identifier shall be unique per request.
Multiple filters are possible per requset.
See spec
GroundingModuleConfig:
type: object
required:
- type
- config
additionalProperties: false
properties:
type:
...
config:
type: object
required:
- input_params
- output_param
additionalProperties: false
properties:
filters:
type: array
items:
oneOf:
- $ref: "#/components/schemas/DocumentGroundingFilter"
description: Document grounding service filters to be used
...
DocumentGroundingFilter:
type: object
required:
- id
- data_repository_type
additionalProperties: false
properties:
id:
$ref: "#/components/schemas/GroundingFilterId"
...
GroundingFilterId:
title: Id
description: Identifier of this SearchFilter - unique per request.
GroundingFilterSearchConfiguration:
...
With the proposed convenience API we are
- limiting users to define exactly one filter - this is why "id" seems unnecessary.
- sending a filter no matter what - is this a requirement, that at least one filter must be present?
- not blocking future changes to cardinality - which is good. Looks like we could easily extend the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Therefore:
Would allow for setting multiple filter
on Grounding
then for 1..*
?
Or will you keep the cardinality 1
?
Is 0
filters an option we have to consider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified the API to allow 1+ filters.
0 filters is not allowed because we have to specify the repository type
// optional filter for document chunks | ||
val databaseFilter = | ||
DocumentGroundingFilter.create() | ||
.id("") | ||
.dataRepositoryType(DataRepositoryType.VECTOR) | ||
.searchConfig(GroundingFilterSearchConfiguration.create().maxChunkCount(1)) | ||
.documentMetadata(List.of(documentMetadata)); | ||
|
||
val groundingConfig = Grounding.create().filter(databaseFilter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Comment)
I was looking into other API options where we could increment a number for id
implicitly, but they weren't really promising:
Using handler
// optional filter for document chunks | |
val databaseFilter = | |
DocumentGroundingFilter.create() | |
.id("") | |
.dataRepositoryType(DataRepositoryType.VECTOR) | |
.searchConfig(GroundingFilterSearchConfiguration.create().maxChunkCount(1)) | |
.documentMetadata(List.of(documentMetadata)); | |
val groundingConfig = Grounding.create().filter(databaseFilter); | |
// optional filter for document chunks | |
val groundingConfig = | |
Grounding.create() | |
.filterForType(DataRepositoryType.VECTOR) | |
.apply(filter -> filter | |
.searchConfig(GroundingFilterSearchConfiguration.create().maxChunkCount(1)) | |
.documentMetadata(List.of(documentMetadata))); |
Using return state
// optional filter for document chunks | |
val databaseFilter = | |
DocumentGroundingFilter.create() | |
.id("") | |
.dataRepositoryType(DataRepositoryType.VECTOR) | |
.searchConfig(GroundingFilterSearchConfiguration.create().maxChunkCount(1)) | |
.documentMetadata(List.of(documentMetadata)); | |
val groundingConfig = Grounding.create().filter(databaseFilter); | |
// optional filter for document chunks | |
val groundingConfig = Grounding.create(); | |
groundingConfig | |
.filterForType(DataRepositoryType.VECTOR) | |
.searchConfig(GroundingFilterSearchConfiguration.create().maxChunkCount(1)) | |
.documentMetadata(List.of(documentMetadata)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a filter for 1 request, the id can be empty
Co-authored-by: Alexander Dümont <22489773+newtork@users.noreply.github.com>
Context
AI/ai-sdk-java-backlog#167.
TheGrounding configuration is full of boilerplate code. I added a layer of convenience.
Feature scope:
Grounding
convenienceDefinition of Done
Error handling created / updated & covered by the tests above