Skip to content
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

fix: add function information to open ai listing #537

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
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;
Expand All @@ -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
Expand Up @@ -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",
Expand Down Expand Up @@ -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; ; ) {
Expand Down