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

test: add aiagent assistant api azure openai python test case #12961

Merged
merged 4 commits into from
Dec 27, 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
2 changes: 2 additions & 0 deletions packages/tests/scripts/pvt.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"remotedebug-aiagent-assistapi-openai-bot-py-win-only",
"remotedebug-aiagent-assistapi-azureopenai-bot-win-only",
"remotedebug-aiagent-assistapi-azureopenai-bot-ts-win-only",
"remotedebug-aiagent-assistapi-azureopenai-bot-py-win-only",
"remotedebug-aiagent-new-azureopenai-bot-py",
"remotedebug-aiagent-new-azureopenai-bot-ts",
"remotedebug-aiagent-new-azureopenai-bot",
Expand All @@ -65,6 +66,7 @@
"localdebug-aiagent-assistapi-openai-bot",
"localdebug-aiagent-assistapi-azureopenai-bot-ts",
"localdebug-aiagent-assistapi-azureopenai-bot",
"localdebug-aiagent-assistapi-azureopenai-bot-py",
"localdebug-aiagent-new-openai-bot-py",
"localdebug-aiagent-new-openai-bot-ts",
"localdebug-aiagent-new-openai-bot",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Env, OpenAiKey } from "../../utils/env";
import { it } from "../../utils/it";
import { editDotEnvFile, validateFileExist } from "../../utils/commonUtils";
import { Executor } from "../../utils/executor";
import os from "os";

describe("Local Debug Tests", function () {
this.timeout(Timeout.testCase);
Expand Down Expand Up @@ -84,7 +85,13 @@ describe("Local Debug Tests", function () {
if (isRealKey) {
console.log("Start to create azure assistant id");

const insertDataCmd = `python src/utils/creator.py --api-key ${azureOpenAiKey}`;
let insertDataCmd = "";
if (os.type() === "Windows_NT") {
insertDataCmd = `python src/utils/creator.py --api-key ${azureOpenAiKey}`;
} else {
insertDataCmd = `python src/utils/creator.py --api-key '${azureOpenAiKey}'`;
}

const { success: insertDataSuccess, stdout: log } =
await Executor.execute(insertDataCmd, projectPath);
// get assistant id from log string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
execCommandIfExist,
createNewProject,
createEnvironmentWithPython,
} from "../../utils/vscodeOperation";
import {
initPage,
Expand All @@ -24,6 +25,7 @@ import { Env, OpenAiKey } from "../../utils/env";
import { it } from "../../utils/it";
import { editDotEnvFile, validateFileExist } from "../../utils/commonUtils";
import { Executor } from "../../utils/executor";
import os from "os";

describe("Remote debug Tests", function () {
this.timeout(Timeout.testAzureCase);
Expand Down Expand Up @@ -74,6 +76,7 @@ describe("Remote debug Tests", function () {
aiType: "Azure OpenAI",
});
validateFileExist(projectPath, "src/app.py");
await createEnvironmentWithPython();
const envPath = path.resolve(projectPath, "env", ".env.dev.user");
const isRealKey = OpenAiKey.azureOpenAiKey ? true : false;
const azureOpenAiKey = OpenAiKey.azureOpenAiKey
Expand All @@ -94,10 +97,49 @@ describe("Remote debug Tests", function () {
azureOpenAiModelDeploymentName
);

{
// create azure assistant need to use local env
const localEnvPath = path.resolve(
projectPath,
"env",
".env.local.user"
);
const azureOpenAiKey = OpenAiKey.azureOpenAiKey
? OpenAiKey.azureOpenAiKey
: "fake";
const azureOpenAiEndpoint = OpenAiKey.azureOpenAiEndpoint
? OpenAiKey.azureOpenAiEndpoint
: "https://test.com";
const azureOpenAiModelDeploymentName =
OpenAiKey.azureOpenAiModelDeploymentName
? OpenAiKey.azureOpenAiModelDeploymentName
: "fake";
editDotEnvFile(
localEnvPath,
"SECRET_AZURE_OPENAI_API_KEY",
azureOpenAiKey
);
editDotEnvFile(
localEnvPath,
"AZURE_OPENAI_ENDPOINT",
azureOpenAiEndpoint
);
editDotEnvFile(
localEnvPath,
"AZURE_OPENAI_MODEL_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
}

if (isRealKey) {
console.log("Start to create azure assistant id");

const insertDataCmd = `python src/utils/creator.py --api-key ${azureOpenAiKey}`;
let insertDataCmd = "";
if (os.type() === "Windows_NT") {
insertDataCmd = `python src/utils/creator.py --api-key ${azureOpenAiKey}`;
} else {
insertDataCmd = `python src/utils/creator.py --api-key '${azureOpenAiKey}'`;
}
const { success: insertDataSuccess, stdout: log } =
await Executor.execute(insertDataCmd, projectPath);
// get assistant id from log string
Expand Down
Loading