-
Notifications
You must be signed in to change notification settings - Fork 479
fix(dotAI): QA fixes - image model default, playground overflow, embeddings host resolution #35716
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
Open
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cf8add9
fix(dotAI): update default image model, fix playground overflow, fix …
ihoffmann-dot 88ba866
fix embeddings host resolution in BulkEmbeddingsRunner and cap image …
ihoffmann-dot 546cc42
fix search form validation, model dropdown, and missing index error r…
ihoffmann-dot 903196d
add integration tests for embeddings host resolution with site-only A…
ihoffmann-dot 986ee28
Merge branch 'main' into dot-ai-langchain-qa-fixes
ihoffmann-dot afac943
Merge branch 'main' into dot-ai-langchain-qa-fixes
ihoffmann-dot d45ba87
fix(dotAI): address Kevin's review comments on image size and model d…
ihoffmann-dot c598a2c
fix: parse multimodal content arrays in toMessages() so vision prompt…
ihoffmann-dot 28fbdd7
refactor: extract toImageContent helper from toMultimodalUserMessage
ihoffmann-dot 17b7bc1
fix: address Claude review — indexExists probe, toImageContent NPE gu…
ihoffmann-dot 4c163b7
Merge branch 'main' into dot-ai-langchain-qa-fixes
ihoffmann-dot 1295436
fix: resolve host-specific AppConfig in workflow AI runners
ihoffmann-dot 01908e3
fix: resolve host-specific AppConfig in workflow AI runners
ihoffmann-dot 539f673
Merge branch 'main' into dot-ai-langchain-qa-fixes
ihoffmann-dot 361b170
fix: pass host-specific AppConfig to getCompletionsAPI in OpenAITrans…
ihoffmann-dot 6fa9c84
Merge branch 'main' into dot-ai-langchain-qa-fixes
ihoffmann-dot 0492c0a
fix: update example imageSize to 1024x1024 in AI config detail
ihoffmann-dot 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
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
126 changes: 126 additions & 0 deletions
126
dotcms-integration/src/test/java/com/dotcms/ai/api/BulkEmbeddingsRunnerTest.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,126 @@ | ||
| package com.dotcms.ai.api; | ||
|
|
||
| import com.dotcms.ai.AiTest; | ||
| import com.dotcms.contenttype.model.type.ContentType; | ||
| import com.dotcms.datagen.SiteDataGen; | ||
| import com.dotcms.datagen.TestDataUtils; | ||
| import com.dotcms.ai.rest.forms.EmbeddingsForm; | ||
| import com.dotcms.util.IntegrationTestInitService; | ||
| import com.dotcms.util.network.IPUtils; | ||
| import com.dotmarketing.beans.Host; | ||
| import com.dotmarketing.business.APILocator; | ||
| import com.dotmarketing.exception.DotDataException; | ||
| import com.dotmarketing.exception.DotSecurityException; | ||
| import com.dotmarketing.portlets.contentlet.model.Contentlet; | ||
| import com.dotmarketing.portlets.languagesmanager.business.LanguageAPI; | ||
| import com.github.tomakehurst.wiremock.WireMockServer; | ||
| import com.liferay.portal.model.User; | ||
| import org.junit.AfterClass; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static com.dotmarketing.util.ThreadUtils.sleep; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| /** | ||
| * Integration tests for {@link BulkEmbeddingsRunner}. | ||
| * | ||
| * <p>The setup intentionally configures AI secrets only on the site host, not on System Host. | ||
| * This validates that the runner resolves the host per-contentlet and uses the correct | ||
| * site config rather than falling back to System Host. | ||
| */ | ||
| public class BulkEmbeddingsRunnerTest { | ||
|
|
||
| private static final int MAX_ATTEMPTS = 30; | ||
|
|
||
| private static User user; | ||
| private static Host host; | ||
| private static LanguageAPI languageApi; | ||
| private static WireMockServer wireMockServer; | ||
| private static ContentType blogContentType; | ||
| private static Contentlet contentlet; | ||
|
|
||
| @BeforeClass | ||
| public static void beforeClass() throws Exception { | ||
| IntegrationTestInitService.getInstance().init(); | ||
| IPUtils.disabledIpPrivateSubnet(true); | ||
| user = APILocator.getUserAPI().getSystemUser(); | ||
| languageApi = APILocator.getLanguageAPI(); | ||
| host = new SiteDataGen().nextPersisted(); | ||
| wireMockServer = AiTest.prepareWireMock(); | ||
| // Configure AI only on the site host — intentionally NOT on System Host | ||
| AiTest.aiAppSecretsWithProviderConfig(host, AiTest.providerConfigJson(AiTest.PORT, AiTest.MODEL)); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void afterClass() throws Exception { | ||
| wireMockServer.stop(); | ||
| IPUtils.disabledIpPrivateSubnet(false); | ||
| if (contentlet != null) { | ||
| try { | ||
| APILocator.getContentletAPI().archive(contentlet, user, false); | ||
| APILocator.getContentletAPI().delete(contentlet, user, false); | ||
| } catch (DotDataException | DotSecurityException e) { | ||
| // ignore | ||
| } | ||
| } | ||
| if (blogContentType != null) { | ||
| try { | ||
| APILocator.getContentTypeAPI(user).delete(blogContentType); | ||
| } catch (DotDataException | DotSecurityException e) { | ||
| // ignore | ||
| } | ||
| } | ||
| AiTest.removeAiAppSecrets(host); | ||
| } | ||
|
|
||
| /** | ||
| * Given a contentlet published on a site that has AI configured, | ||
| * and System Host does NOT have AI configured, | ||
| * When BulkEmbeddingsRunner processes that contentlet, | ||
| * Then embeddings should be generated using the site config. | ||
| */ | ||
| @Test | ||
| public void test_run_generatesEmbeddings_withSiteOnlyConfig() throws Exception { | ||
| DotAIAPIFacadeImpl.setDefaultEmbeddingsAPIProvider( | ||
| new DotAIAPIFacadeImpl.DefaultEmbeddingsAPIProvider()); | ||
|
|
||
| blogContentType = TestDataUtils.getBlogLikeContentType("blog", host); | ||
| final String text = "BulkEmbeddingsRunner should resolve the host from the contentlet " | ||
| + "and use the site config rather than falling back to System Host."; | ||
| contentlet = TestDataUtils.withEmbeddings( | ||
| true, | ||
| host, | ||
| languageApi.getDefaultLanguage().getId(), | ||
| blogContentType.id(), | ||
| text); | ||
| APILocator.getContentletAPI().publish(contentlet, user, false); | ||
|
|
||
| final EmbeddingsForm form = new EmbeddingsForm.Builder() | ||
| .indexName("default") | ||
| .build(); | ||
| new BulkEmbeddingsRunner(List.of(contentlet.getInode()), form).run(); | ||
|
|
||
| assertTrue( | ||
| "Expected embeddings after BulkEmbeddingsRunner.run() with site-only AI config", | ||
| waitForEmbeddings(contentlet, text)); | ||
| } | ||
|
|
||
| private static boolean waitForEmbeddings(final Contentlet contentlet, final String text) { | ||
| int count = 0; | ||
| boolean exists = APILocator.getDotAIAPI().getEmbeddingsAPI(host) | ||
| .embeddingExists(contentlet.getInode(), "default", text); | ||
| while (!exists) { | ||
| if (count++ > MAX_ATTEMPTS) { | ||
| break; | ||
| } | ||
| sleep(500); | ||
| exists = APILocator.getDotAIAPI().getEmbeddingsAPI(host) | ||
| .embeddingExists(contentlet.getInode(), "default", text); | ||
| } | ||
| return exists; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.