Skip to content

Commit

Permalink
fix: add function information to open ai listing (#537)
Browse files Browse the repository at this point in the history
artsiomkorzun authored Oct 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 00c75ec commit afc6e45
Showing 3 changed files with 134 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ public ApplicationData mapApplication(Application application) {

String reference = application.getReference();
data.setReference(reference == null ? application.getName() : reference);
data.setFunction(application.getFunction());

return data;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.epam.aidial.core.server.data;

import com.epam.aidial.core.config.Application;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
@@ -15,4 +16,6 @@ public class ApplicationData extends DeploymentData {
setObject("application");
setScaleSettings(null);
}

private Application.Function function;
}
Original file line number Diff line number Diff line change
@@ -568,7 +568,7 @@ void testControllerError() {
""");
verify(response, 200);

response = awaitApplicationStatus("/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app", "FAILED");;
response = awaitApplicationStatus("/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app", "FAILED");
verifyJsonNotExact(response, 200, """
{
"name" : "applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app",
@@ -737,6 +737,135 @@ void testLogs() {
""");
}

@Test
void testOpenAiApi() {
testApplicationStarted();

Response response = send(HttpMethod.GET, "/openai/applications/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app");
verifyJsonNotExact(response, 200, """
{
"id" : "applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app",
"application" : "applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app",
"display_name" : "My App",
"display_version" : "1.0",
"icon_url" : "http://application1/icon.svg",
"description" : "My App Description",
"reference" : "@ignore",
"owner" : "organization-owner",
"object" : "application",
"status" : "succeeded",
"created_at" : 1672534800,
"updated_at" : 1672534800,
"features" : {
"rate" : false,
"tokenize" : false,
"truncate_prompt" : false,
"configuration" : false,
"system_prompt" : true,
"tools" : false,
"seed" : false,
"url_attachments" : false,
"folder_attachments" : false,
"allow_resume" : true,
"accessible_by_per_request_key" : true
},
"defaults" : { },
"description_keywords" : [ ],
"function" : {
"id" : "0123",
"runtime" : "python3.11",
"author_bucket" : "3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST",
"source_folder" : "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app/",
"target_folder" : "files/2CZ9i2bcBACFts8JbBu3MdcF8sdwTbELGXeFRV6CVDwnPEU8vWC1y8PpXyRChHQvzt/",
"status" : "STARTED",
"mapping" : {
"completion" : "/application"
},
"env" : {
"VAR" : "VAL"
}
}
}
""");

response = send(HttpMethod.GET, "/openai/applications");
verifyJsonNotExact(response, 200, """
{
"data" : [ {
"id" : "app",
"application" : "app",
"display_name" : "10k",
"icon_url" : "http://localhost:7001/logo10k.png",
"description" : "Some description of the application for testing",
"reference" : "app",
"owner" : "organization-owner",
"object" : "application",
"status" : "succeeded",
"created_at" : 1672534800,
"updated_at" : 1672534800,
"features" : {
"rate" : true,
"tokenize" : false,
"truncate_prompt" : false,
"configuration" : true,
"system_prompt" : false,
"tools" : false,
"seed" : false,
"url_attachments" : false,
"folder_attachments" : false,
"allow_resume" : true,
"accessible_by_per_request_key" : true
},
"defaults" : { },
"description_keywords" : [ ]
}, {
"id" : "applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app",
"application" : "applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app",
"display_name" : "My App",
"display_version" : "1.0",
"icon_url" : "http://application1/icon.svg",
"description" : "My App Description",
"reference" : "@ignore",
"owner" : "organization-owner",
"object" : "application",
"status" : "succeeded",
"created_at" : 1672534800,
"updated_at" : 1672534800,
"features" : {
"rate" : false,
"tokenize" : false,
"truncate_prompt" : false,
"configuration" : false,
"system_prompt" : true,
"tools" : false,
"seed" : false,
"url_attachments" : false,
"folder_attachments" : false,
"allow_resume" : true,
"accessible_by_per_request_key" : true
},
"defaults" : { },
"description_keywords" : [ ],
"function" : {
"id" : "0123",
"runtime" : "python3.11",
"author_bucket" : "3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST",
"source_folder" : "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/my-app/",
"target_folder" : "files/2CZ9i2bcBACFts8JbBu3MdcF8sdwTbELGXeFRV6CVDwnPEU8vWC1y8PpXyRChHQvzt/",
"status" : "STARTED",
"mapping" : {
"completion" : "/application"
},
"env" : {
"VAR" : "VAL"
}
}
} ],
"object" : "list"
}
""");
}

@SneakyThrows
private Response awaitApplicationStatus(String path, String status) {
for (long deadline = System.currentTimeMillis() + 10_000; ; ) {

0 comments on commit afc6e45

Please sign in to comment.