-
Notifications
You must be signed in to change notification settings - Fork 22
refactor: use single factory instead of inheritance for prompt registry clients #1046
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
Open
vladimir-a-sap
wants to merge
11
commits into
v2
Choose a base branch
from
factory-instead-of-inheritance-for-prompt-registry-clients
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f561b57
rework Prompt and OrchestrationConfig clients
vladimir-a-sap 08cfd28
create AiCoreService in PromptRegistryClient only once
vladimir-a-sap eb3f68a
address pr feedback
vladimir-a-sap 2bab710
polish code style
vladimir-a-sap 82f382e
polish code style
vladimir-a-sap d2104a8
improve code style
vladimir-a-sap 13d8aa0
improve code style
vladimir-a-sap 945c411
Formatting
bot-sdk-js 1266c40
improve code style
vladimir-a-sap a8234b2
Merge branch 'factory-instead-of-inheritance-for-prompt-registry-clie…
vladimir-a-sap 2fcc3a3
Formatting
bot-sdk-js File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...es/prompt-registry/src/main/java/com/sap/ai/sdk/prompt/registry/PromptRegistryClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.sap.ai.sdk.prompt.registry; | ||
|
|
||
| import com.sap.ai.sdk.core.AiCoreService; | ||
| import com.sap.ai.sdk.prompt.registry.client.OrchestrationConfigsApi; | ||
| import com.sap.ai.sdk.prompt.registry.client.PromptTemplatesApi; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * Unified client to use Prompt Registry API | ||
| * | ||
| * @since 2.0 | ||
| */ | ||
| public class PromptRegistryClient { | ||
|
|
||
| private final AiCoreService aiCoreService; | ||
|
|
||
| /** Constructs default PromptRegistryClient */ | ||
| public PromptRegistryClient() { | ||
| this(new AiCoreService()); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs PromptRegistryClient with customized AiCoreService | ||
| * | ||
| * @param service customized AiCoreService | ||
| */ | ||
| public PromptRegistryClient(@Nonnull final AiCoreService service) { | ||
| aiCoreService = service; | ||
| } | ||
|
|
||
| /** | ||
| * Get the prompt templates client | ||
| * | ||
| * @return the client | ||
| */ | ||
| @Nonnull | ||
| public PromptTemplatesApi prompt() { | ||
| return new PromptTemplatesApi(PromptClientMixin.addMixin(aiCoreService)); | ||
| } | ||
|
|
||
| /** | ||
| * Get the orchestration configs client | ||
| * | ||
| * @return the client | ||
| */ | ||
| @Nonnull | ||
| public OrchestrationConfigsApi orchestrationConfig() { | ||
| return new OrchestrationConfigsApi(OrchestrationConfigMixin.addMixin(aiCoreService)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,30 @@ | |||||
|
|
||||||
| - [RPT] SAP-RPT was updated to the newer 1.6.0 API | ||||||
| - [Orchestration] Spring AI support was upgraded to version `2.0.1` | ||||||
| - [Core] OrchestrationConfigClient and PromptClient were reworked into unified PromptRegistryClient, | ||||||
| see migration guide below for additional information | ||||||
|
|
||||||
| #### Prompt registry client Migration Guide | ||||||
|
|
||||||
| OrchestrationConfigClient and PromptClient were replaced with unified PromptRegistryClient, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| OrchestrationConfigClient: | ||||||
| ```diff | ||||||
| -var orchestrationConfigsClient = new OrchestrationConfigClient(); | ||||||
| -var configs = orchestrationConfigsClient.listOrchestrationConfigs(); | ||||||
|
|
||||||
| +var orchestractionConfigsClient = new PromptRegistryClient().orchestrationConfig(); | ||||||
| +var configs = orchestractionConfigsClient.listOrchestrationConfigs(); | ||||||
| ``` | ||||||
|
|
||||||
| PromptRegistryClient: | ||||||
| ```diff | ||||||
| -var promptClient = new PromptClient(); | ||||||
| -var templates = promptClient.listPromptTemplates(); | ||||||
|
|
||||||
| +var promptClient = new PromptRegistryClient().prompt(); | ||||||
| +var templates = promptClient.listPromptTemplates(); | ||||||
| ``` | ||||||
|
|
||||||
| #### Spring AI 2.0.1 Migration Guide | ||||||
|
|
||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.