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

feat: optimize npm run config for china region #541

Merged
merged 3 commits into from
Feb 27, 2025
Merged
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
43 changes: 26 additions & 17 deletions source/infrastructure/cli/magic-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const embeddingModels = [
const supportedRegions = Object.values(SupportedRegion) as string[];
const supportedBedrockRegions = Object.values(SupportedBedrockRegion) as string[];

const llms = [
let llms = [
{
provider: "bedrock",
name: "anthropic.claude-3-sonnet-20240229-v1:0",
Expand All @@ -57,11 +57,11 @@ async function getAwsAccountAndRegion() {
let AWS_ACCOUNT;
let AWS_REGION;

// Create STS client
const profile = process.env.AWS_PROFILE || "default";
const aws_profile = process.env.AWS_PROFILE || "default";

// Create STS client
const stsClient = new STSClient({
credentials: fromIni({ profile: profile })
credentials: fromIni({ profile: aws_profile })
});

try {
Expand Down Expand Up @@ -197,6 +197,7 @@ async function processCreateOptions(options: any): Promise<void> {
]

const mandatoryQuestionAnswers: any = await prompt(mandatoryQuestions);
const deployInChina = mandatoryQuestionAnswers.intelliAgentDeployRegion.includes("cn");

let questions = [
{
Expand Down Expand Up @@ -332,36 +333,38 @@ async function processCreateOptions(options: any): Promise<void> {
initial: options.enableChat ?? true,
},
{
type: "input",
type: "select",
name: "bedrockRegion",
hint: "ENTER to confirm selection",
message: "Which region would you like to use Bedrock?",
initial: options.bedrockRegion ?? mandatoryQuestionAnswers.intelliAgentDeployRegion,
validate(bedrockRegion: string) {
if (Object.values(supportedBedrockRegions).includes(bedrockRegion)) {
return true;
choices: supportedBedrockRegions.map((region) => ({ name: region, value: region })),
initial: options.bedrockRegion,
validate(value: string) {
if ((this as any).state.answers.bedrockRegion) {
return value ? true : "Select a Bedrock Region";
}
return "Enter a valid region for Bedrock. Supported regions: " + supportedBedrockRegions.join(", ");
return true;
},
skip(): boolean {
return (!(this as any).state.answers.enableChat);
return (deployInChina);
},
},
{
type: "confirm",
name: "useOpenSourceLLM",
message: "Do you want to use open source LLM(eg. Qwen, ChatGLM, IntermLM)?",
initial: options.useOpenSourceLLM ?? true,
initial: options.useOpenSourceLLM ?? false,
skip(): boolean {
return (!(this as any).state.answers.enableChat);
return (!(this as any).state.answers.enableChat || deployInChina);
},
},
{
type: "confirm",
name: "enableConnect",
message: "Do you want to integrate it with Amazon Connect?",
initial: options.enableConnect ?? true,
initial: options.enableConnect ?? false,
skip(): boolean {
return (!(this as any).state.answers.enableChat);
return (!(this as any).state.answers.enableChat || deployInChina);
},
},
{
Expand All @@ -378,8 +381,7 @@ async function processCreateOptions(options: any): Promise<void> {
return true;
},
skip(): boolean {
return (!(this as any).state.answers.enableKnowledgeBase &&
!(this as any).state.answers.enableChat);
return (!(this as any).state.answers.enableKnowledgeBase || deployInChina);
},
},
{
Expand Down Expand Up @@ -449,6 +451,13 @@ async function processCreateOptions(options: any): Promise<void> {
};
}

// Modify the config for China Region
if (deployInChina) {
answers.bedrockRegion = "";
answers.defaultEmbedding = "bce-embedding-and-bge-reranker";
llms = []
}

// Create the config object
const config = {
prefix: mandatoryQuestionAnswers.prefix,
Expand Down
Loading