From 7dcf05e2f9a75c32b06196352ad50ae36172467e Mon Sep 17 00:00:00 2001 From: Aliaksandr Stsiapanay Date: Wed, 6 Nov 2024 15:47:17 +0300 Subject: [PATCH] feat: Create feature flag for the support of content parts #513 (#563) --- .../com/epam/aidial/core/config/Features.java | 1 + .../core/server/config/FileConfigStore.java | 3 ++ .../controller/DeploymentController.java | 4 +++ .../aidial/core/server/data/FeaturesData.java | 1 + .../server/ApplicationDeploymentApiTest.java | 9 +++-- .../core/server/CustomApplicationApiTest.java | 33 ++++++++++++------- .../epam/aidial/core/server/ListingTest.java | 12 ++++--- 7 files changed, 45 insertions(+), 18 deletions(-) diff --git a/config/src/main/java/com/epam/aidial/core/config/Features.java b/config/src/main/java/com/epam/aidial/core/config/Features.java index 1607dbf54..c4afb5c84 100644 --- a/config/src/main/java/com/epam/aidial/core/config/Features.java +++ b/config/src/main/java/com/epam/aidial/core/config/Features.java @@ -33,4 +33,5 @@ public class Features { @JsonAlias({"allowResume", "allow_resume"}) private Boolean allowResume; private Boolean accessibleByPerRequestKey; + private Boolean contentPartsSupported; } \ No newline at end of file diff --git a/server/src/main/java/com/epam/aidial/core/server/config/FileConfigStore.java b/server/src/main/java/com/epam/aidial/core/server/config/FileConfigStore.java index be4d78d2a..b90b5e3a5 100644 --- a/server/src/main/java/com/epam/aidial/core/server/config/FileConfigStore.java +++ b/server/src/main/java/com/epam/aidial/core/server/config/FileConfigStore.java @@ -194,5 +194,8 @@ private static void setMissingFeatures(Deployment model, Features features) { if (modelFeatures.getAccessibleByPerRequestKey() == null) { modelFeatures.setAccessibleByPerRequestKey(features.getAccessibleByPerRequestKey()); } + if (modelFeatures.getContentPartsSupported() == null) { + modelFeatures.setContentPartsSupported(features.getContentPartsSupported()); + } } } diff --git a/server/src/main/java/com/epam/aidial/core/server/controller/DeploymentController.java b/server/src/main/java/com/epam/aidial/core/server/controller/DeploymentController.java index 808b6bbc7..ad43c4a52 100644 --- a/server/src/main/java/com/epam/aidial/core/server/controller/DeploymentController.java +++ b/server/src/main/java/com/epam/aidial/core/server/controller/DeploymentController.java @@ -155,6 +155,10 @@ static FeaturesData createFeatures(Features features) { data.setAccessibleByPerRequestKey(features.getAccessibleByPerRequestKey()); } + if (features.getContentPartsSupported() != null) { + data.setContentPartsSupported(features.getContentPartsSupported()); + } + return data; } } \ No newline at end of file diff --git a/server/src/main/java/com/epam/aidial/core/server/data/FeaturesData.java b/server/src/main/java/com/epam/aidial/core/server/data/FeaturesData.java index 9afb88a22..96b79ffd5 100644 --- a/server/src/main/java/com/epam/aidial/core/server/data/FeaturesData.java +++ b/server/src/main/java/com/epam/aidial/core/server/data/FeaturesData.java @@ -21,4 +21,5 @@ public class FeaturesData { private boolean folderAttachments = false; private boolean allowResume = true; private boolean accessibleByPerRequestKey = true; + private boolean contentPartsSupported = false; } \ No newline at end of file diff --git a/server/src/test/java/com/epam/aidial/core/server/ApplicationDeploymentApiTest.java b/server/src/test/java/com/epam/aidial/core/server/ApplicationDeploymentApiTest.java index e5873b7f9..7ae13f05b 100644 --- a/server/src/test/java/com/epam/aidial/core/server/ApplicationDeploymentApiTest.java +++ b/server/src/test/java/com/epam/aidial/core/server/ApplicationDeploymentApiTest.java @@ -767,7 +767,8 @@ void testOpenAiApi() { "url_attachments" : false, "folder_attachments" : false, "allow_resume" : true, - "accessible_by_per_request_key" : true + "accessible_by_per_request_key" : true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords" : [ ], @@ -814,7 +815,8 @@ void testOpenAiApi() { "url_attachments" : false, "folder_attachments" : false, "allow_resume" : true, - "accessible_by_per_request_key" : true + "accessible_by_per_request_key" : true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords" : [ ] @@ -842,7 +844,8 @@ void testOpenAiApi() { "url_attachments" : false, "folder_attachments" : false, "allow_resume" : true, - "accessible_by_per_request_key" : true + "accessible_by_per_request_key" : true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords" : [ ], diff --git a/server/src/test/java/com/epam/aidial/core/server/CustomApplicationApiTest.java b/server/src/test/java/com/epam/aidial/core/server/CustomApplicationApiTest.java index 839bcf177..21373ee04 100644 --- a/server/src/test/java/com/epam/aidial/core/server/CustomApplicationApiTest.java +++ b/server/src/test/java/com/epam/aidial/core/server/CustomApplicationApiTest.java @@ -334,7 +334,8 @@ void testApplicationSharing() { "url_attachments" : false, "folder_attachments" : false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords":[] @@ -369,7 +370,8 @@ void testApplicationSharing() { "url_attachments":false, "folder_attachments":false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults":{}, "description_keywords":[] @@ -398,7 +400,8 @@ void testApplicationSharing() { "url_attachments" : false, "folder_attachments" : false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords":[] @@ -436,7 +439,8 @@ void testApplicationSharing() { "url_attachments":false, "folder_attachments":false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults":{}, "description_keywords":[] @@ -465,7 +469,8 @@ void testApplicationSharing() { "url_attachments" : false, "folder_attachments" : false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords":[] @@ -576,7 +581,8 @@ void testApplicationPublication() { "url_attachments":false, "folder_attachments":false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults":{}, "description_keywords":[] @@ -605,7 +611,8 @@ void testApplicationPublication() { "url_attachments" : false, "folder_attachments" : false, "allow_resume":true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords":[] @@ -646,7 +653,8 @@ void testOpenAiApplicationListing() { "url_attachments":false, "folder_attachments":false, "allow_resume": true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults":{}, "description_keywords":[] @@ -699,7 +707,8 @@ void testOpenAiApplicationListing() { "url_attachments":false, "folder_attachments":false, "allow_resume": true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults":{}, "description_keywords":[] @@ -734,7 +743,8 @@ void testOpenAiApplicationListing() { "url_attachments":false, "folder_attachments":false, "allow_resume": true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults":{}, "description_keywords":[] @@ -763,7 +773,8 @@ void testOpenAiApplicationListing() { "url_attachments" : false, "folder_attachments" : false, "allow_resume": true, - "accessible_by_per_request_key": true + "accessible_by_per_request_key": true, + "content_parts_supported": false }, "defaults" : { }, "description_keywords":[] diff --git a/server/src/test/java/com/epam/aidial/core/server/ListingTest.java b/server/src/test/java/com/epam/aidial/core/server/ListingTest.java index 41fd1c0e9..585bc5eb7 100644 --- a/server/src/test/java/com/epam/aidial/core/server/ListingTest.java +++ b/server/src/test/java/com/epam/aidial/core/server/ListingTest.java @@ -51,7 +51,8 @@ void testFeaturesEmbedding(Vertx vertx, VertxTestContext context) { { "rate": false, "tokenize": false, "truncate_prompt": false , "system_prompt": true, "tools": false, "seed": false , "url_attachments": false, "folder_attachments": false - , "configuration": false, "allow_resume": true, "accessible_by_per_request_key": true + , "configuration": false, "allow_resume": true, "accessible_by_per_request_key": true, + "content_parts_supported": false } """)); } @@ -62,7 +63,8 @@ void testFeaturesModel(Vertx vertx, VertxTestContext context) { { "rate": true, "tokenize": true, "truncate_prompt": true , "system_prompt": true, "tools": true, "seed": true , "url_attachments": true, "folder_attachments": false - , "configuration": false, "allow_resume": true, "accessible_by_per_request_key": true + , "configuration": false, "allow_resume": true, "accessible_by_per_request_key": true, + "content_parts_supported": false } """)); } @@ -73,7 +75,8 @@ void testFeaturesApplication(Vertx vertx, VertxTestContext context) { { "rate": true, "tokenize": false, "truncate_prompt": false , "system_prompt": false, "tools": false, "seed": false , "url_attachments": false, "folder_attachments": false - , "configuration": true, "allow_resume": true, "accessible_by_per_request_key": true + , "configuration": true, "allow_resume": true, "accessible_by_per_request_key": true, + "content_parts_supported": false } """)); } @@ -84,7 +87,8 @@ void testFeaturesAssistant(Vertx vertx, VertxTestContext context) { { "rate": true, "tokenize": false, "truncate_prompt": false , "system_prompt": true, "tools": false, "seed": false , "url_attachments": false, "folder_attachments": false - , "configuration": false, "allow_resume": true, "accessible_by_per_request_key": true + , "configuration": false, "allow_resume": true, "accessible_by_per_request_key": true, + "content_parts_supported": false } """)); }