Skip to content

Commit

Permalink
Merge pull request #15 from NipunaRanasinghe/main
Browse files Browse the repository at this point in the history
Add connector icon and update tests
  • Loading branch information
NipunaRanasinghe authored Aug 18, 2024
2 parents 7f7affc + a3ed842 commit 99c45b8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 28 deletions.
4 changes: 2 additions & 2 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ name = "openai.assistants"
version = "1.0.0"
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = ["AI/assitants", "vendor/OpenAI", "cost/paid", "custom-bot","run", "threads"]
# icon = "icon.png" TODO: Add icon
keywords = ["AI/assitants", "vendor/OpenAI", "cost/paid", "custom-bot", "run", "threads"]
icon = "icon.png"
repository = "https://github.com/ballerina-platform/module-ballerinax-openai.assistants"

[build-options]
Expand Down
4 changes: 0 additions & 4 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"}
]
modules = [
{org = "ballerina", packageName = "io", moduleName = "io"}
]

[[package]]
org = "ballerina"
Expand Down Expand Up @@ -325,7 +322,6 @@ version = "1.0.0"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "http"},
{org = "ballerina", name = "io"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "os"},
{org = "ballerina", name = "test"},
Expand Down
Binary file added ballerina/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 2 additions & 20 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// specific language governing permissions and limitations
// under the License.

import ballerina/io;
import ballerina/os;
import ballerina/test;

Expand Down Expand Up @@ -49,7 +48,6 @@ function testDeleteMessage() returns error? {
}

DeleteMessageResponse res = check openAIAssistant->/threads/[threadId]/messages/[messageId].delete(headers);
io:println("Message deleted successfully: ", res);
test:assertTrue(res.deleted == true, msg = "Failed to delete message");
}

Expand All @@ -63,7 +61,6 @@ function testGetMessage() returns error? {
}

MessageObject res = check openAIAssistant->/threads/[threadId]/messages/[messageId].get(headers);
io:println("Message Details: ", res);
test:assertEquals(res.id, messageId, msg = "Retrieved message ID does not match the requested ID");
}

Expand All @@ -82,7 +79,6 @@ function testCreateMessage() returns error? {
};

MessageObject res = check openAIAssistant->/threads/[threadId]/messages.post(createMsgReq, headers);
io:println("Created Message: ", res);
test:assertNotEquals(res.id, "");
messageId = res.id;
}
Expand All @@ -97,7 +93,6 @@ function testListMessages() returns error? {
}

ListMessagesResponse res = check openAIAssistant->/threads/[threadId]/messages.get(headers);
io:println("ListMessagesResponse: ", res);
test:assertTrue(res is ListMessagesResponse);
}

Expand All @@ -117,7 +112,6 @@ function testCreateRun() returns error? {
};

RunObject resp = check openAIAssistant->/threads/[threadId]/runs.post(runReq, headers);
io:println("Created Run: ", resp);
test:assertNotEquals(resp.id, "", msg = "Run creation failed: No Run ID returned");
runId = resp.id;
}
Expand All @@ -128,7 +122,6 @@ function testCreateRun() returns error? {
}
function testListRuns() returns error? {
ListRunsResponse res = check openAIAssistant->/threads/[threadId]/runs.get(headers);
io:println("Runs in Thread: ", res.data);
test:assertNotEquals(res.data.length(), 0, msg = "No runs found in the thread");
}

Expand All @@ -148,7 +141,6 @@ function testCreateThreadAndRun() returns error? {
// };

// RunObject resp = check openAIAssistant->/threads/runs.post(createThreadAndRunReq, headers);
// io:println("Created Thread and Run: ", resp);
// test:assertNotEquals(resp.id, "", msg = "Thread and Run creation failed: No Run ID returned");
}

Expand All @@ -161,7 +153,6 @@ function testCreateThread() returns error? {
};

ThreadObject response = check openAIAssistant->/threads.post(createThreadReq, headers);
io:println("Thread ID: ", response.id);
threadId = response.id;
test:assertNotEquals(response.id, "");
}
Expand All @@ -171,12 +162,11 @@ function testCreateThread() returns error? {
groups: ["live_tests", "mock_tests"]
}
function testDeleteAssistant() returns error? {
if (assistantId == "") {
if assistantId == "" {
test:assertFail(msg = "No assistant ID available. Ensure assistant creation test runs first.");
}

DeleteAssistantResponse res = check openAIAssistant->/assistants/[assistantId].delete(headers);
io:println("Assistant deleted successfully: ", res);
test:assertTrue(res.deleted == true, msg = "Failed to delete assistant");
}

Expand All @@ -185,12 +175,11 @@ function testDeleteAssistant() returns error? {
groups: ["live_tests", "mock_tests"]
}
function testGetAssistant() returns error? {
if (assistantId == "") {
if assistantId == "" {
test:assertFail(msg = "No assistant ID available. Ensure you set assistantId before running this test.");
}

AssistantObject res = check openAIAssistant->/assistants/[assistantId].get(headers);
io:println("Assistant Details: ", res);
test:assertEquals(res.id, assistantId);
}

Expand All @@ -201,7 +190,6 @@ function testGetAssistant() returns error? {
function testListRunSteps() returns error? {
ListRunStepsResponse res = check openAIAssistant->/threads/[threadId]/runs/[runId]/steps.get(headers);
test:assertTrue(res is ListRunStepsResponse);
io:println("Steps in Run: ", res.data);
stepId = res.data.length() > 0 ? res.data[0].id : "";
}

Expand All @@ -222,7 +210,6 @@ function testCreateAssistant() returns error? {
};

AssistantObject res = check openAIAssistant->/assistants.post(request, headers);
io:println("Assistant ID: ", res.id);
assistantId = res.id;
test:assertNotEquals(res.id, "");
}
Expand All @@ -238,7 +225,6 @@ function testListAssistants() returns error? {
};

ListAssistantsResponse res = check openAIAssistant->/assistants.get(headers, query);
io:println("Assistant List: ", res.data);
test:assertTrue(res is ListAssistantsResponse);
}

Expand All @@ -252,7 +238,6 @@ function testGetRunStep() returns error? {
}
else {
RunStepObject res = check openAIAssistant->/threads/[threadId]/runs/[runId]/steps/[stepId].get(headers);
io:println("Run Step Details: ", res);
test:assertEquals(res.id, stepId, msg = "Retrieved step ID does not match the requested ID");
}
}
Expand All @@ -267,7 +252,6 @@ function testDeleteThread() returns error? {
}

DeleteThreadResponse res = check openAIAssistant->/threads/[threadId].delete(headers);
io:println("Thread deleted successfully: ", res);
test:assertTrue(res.deleted == true, msg = "Failed to delete thread");
}

Expand All @@ -281,7 +265,6 @@ function testGetThread() returns error? {
}

ThreadObject res = check openAIAssistant->/threads/[threadId].get(headers);
io:println("Thread Details: ", res);
test:assertEquals(res.id, threadId);
}

Expand All @@ -291,6 +274,5 @@ function testGetThread() returns error? {
}
function testGetRun() returns error? {
RunObject res = check openAIAssistant->/threads/[threadId]/runs/[runId].get(headers);
io:println("Run Details: ", res);
test:assertEquals(res.id, runId, msg = "Retrieved run ID does not match the requested ID");
}
4 changes: 2 additions & 2 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ name = "openai.assistants"
version = "@toml.version@"
license = ["Apache-2.0"]
authors = ["Ballerina"]
keywords = ["AI/assitants", "vendor/OpenAI", "cost/paid", "custom-bot","run", "threads"]
# icon = "icon.png" TODO: Add icon
keywords = ["AI/assitants", "vendor/OpenAI", "cost/paid", "custom-bot", "run", "threads"]
icon = "icon.png"
repository = "https://github.com/ballerina-platform/module-ballerinax-openai.assistants"

[build-options]
Expand Down

0 comments on commit 99c45b8

Please sign in to comment.