Skip to content

Commit

Permalink
test: support real key
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan_Chen committed Jul 30, 2024
1 parent e235bd0 commit d0b1e57
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,58 @@ describe("Local Debug Tests", function () {
OpenAiKey.azureOpenAiModelDeploymentName
? OpenAiKey.azureOpenAiModelDeploymentName
: "fake";

const embeddingDeploymentName =
OpenAiKey.azureOpenAiEmbeddingDeploymentName ?? "fake";

const searchKey = isRealKey ? azSearchHelper.apiKey : "fake";
const searchEndpoint = isRealKey
? azSearchHelper.endpoint
: "https://test.com";
editDotEnvFile(envPath, "SECRET_AZURE_OPENAI_API_KEY", azureOpenAiKey);
editDotEnvFile(envPath, "AZURE_OPENAI_ENDPOINT", azureOpenAiEndpoint);
editDotEnvFile(
envPath,
"AZURE_OPENAI_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
const embeddingDeploymentName =
OpenAiKey.azureOpenAiEmbeddingDeploymentName ?? "fake";
editDotEnvFile(
envPath,
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
embeddingDeploymentName
);
const searchKey = isRealKey ? azSearchHelper.apiKey : "fake";
const searchEndpoint = isRealKey
? azSearchHelper.endpoint
: "https://test.com";
editDotEnvFile(envPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(envPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// prepare for the npm run indexer:create
const testToolEnvPath = path.resolve(
projectPath,
"env",
".env.testtool.user"
);
editDotEnvFile(
testToolEnvPath,
"SECRET_AZURE_OPENAI_API_KEY",
azureOpenAiKey
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_ENDPOINT",
azureOpenAiEndpoint
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
embeddingDeploymentName
);
editDotEnvFile(testToolEnvPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(testToolEnvPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// create azure search data
if (isRealKey) {
console.log("Start to create azure search data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,58 @@ describe("Local Debug Tests", function () {
OpenAiKey.azureOpenAiModelDeploymentName
? OpenAiKey.azureOpenAiModelDeploymentName
: "fake";

const embeddingDeploymentName =
OpenAiKey.azureOpenAiEmbeddingDeploymentName ?? "fake";

const searchKey = isRealKey ? azSearchHelper.apiKey : "fake";
const searchEndpoint = isRealKey
? azSearchHelper.endpoint
: "https://test.com";
editDotEnvFile(envPath, "SECRET_AZURE_OPENAI_API_KEY", azureOpenAiKey);
editDotEnvFile(envPath, "AZURE_OPENAI_ENDPOINT", azureOpenAiEndpoint);
editDotEnvFile(
envPath,
"AZURE_OPENAI_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
const embeddingDeploymentName =
OpenAiKey.azureOpenAiEmbeddingDeploymentName ?? "fake";
editDotEnvFile(
envPath,
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
embeddingDeploymentName
);
const searchKey = isRealKey ? azSearchHelper.apiKey : "fake";
const searchEndpoint = isRealKey
? azSearchHelper.endpoint
: "https://test.com";
editDotEnvFile(envPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(envPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// prepare for the npm run indexer:create
const testToolEnvPath = path.resolve(
projectPath,
"env",
".env.testtool.user"
);
editDotEnvFile(
testToolEnvPath,
"SECRET_AZURE_OPENAI_API_KEY",
azureOpenAiKey
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_ENDPOINT",
azureOpenAiEndpoint
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
embeddingDeploymentName
);
editDotEnvFile(testToolEnvPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(testToolEnvPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// create azure search data
if (isRealKey) {
console.log("Start to create azure search data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,35 @@ describe("Remote debug Tests", function () {
editDotEnvFile(envPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(envPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// prepare for the npm run indexer:create
const testToolEnvPath = path.resolve(
projectPath,
"env",
".env.testtool.user"
);
editDotEnvFile(
testToolEnvPath,
"SECRET_AZURE_OPENAI_API_KEY",
azureOpenAiKey
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_ENDPOINT",
azureOpenAiEndpoint
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
embeddingDeploymentName
);
editDotEnvFile(testToolEnvPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(testToolEnvPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// create azure search data
if (isRealKey) {
console.log("Start to create azure search data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,34 @@ describe("Remote debug Tests", function () {
editDotEnvFile(envPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(envPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);

// prepare for the npm run indexer:create
const testToolEnvPath = path.resolve(
projectPath,
"env",
".env.testtool.user"
);
editDotEnvFile(
testToolEnvPath,
"SECRET_AZURE_OPENAI_API_KEY",
azureOpenAiKey
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_ENDPOINT",
azureOpenAiEndpoint
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_DEPLOYMENT_NAME",
azureOpenAiModelDeploymentName
);
editDotEnvFile(
testToolEnvPath,
"AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
embeddingDeploymentName
);
editDotEnvFile(testToolEnvPath, "SECRET_AZURE_SEARCH_KEY", searchKey);
editDotEnvFile(testToolEnvPath, "AZURE_SEARCH_ENDPOINT", searchEndpoint);
// create azure search data
if (isRealKey) {
console.log("Start to create azure search data");
Expand Down

0 comments on commit d0b1e57

Please sign in to comment.