Skip to content

Commit

Permalink
Merge pull request #520 from aws-samples/bedrock-api
Browse files Browse the repository at this point in the history
fix: fix glue issue
  • Loading branch information
NingLu authored Jan 22, 2025
2 parents 1bbdd21 + 03a3de2 commit 6f3f74d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ export class KnowledgeBaseStack extends NestedStack implements KnowledgeBaseStac
"--REGION": process.env.CDK_DEFAULT_REGION || "-",
"--BEDROCK_REGION": props.config.chat.bedrockRegion,
"--API_INFERENCE_ENABLED": props.config.chat.apiInference.enabled.toString(),
"--API_INFERENCE_PROVIDER": props.config.chat.apiInference.apiInferenceProvider,
"--API_ENDPOINT": props.config.chat.apiInference.apiEndpoint,
"--API_KEY_ARN": props.config.chat.apiInference.apiKey,
"--API_INFERENCE_PROVIDER": props.config.chat.apiInference.apiInferenceProvider || "-",
"--API_ENDPOINT": props.config.chat.apiInference.apiEndpoint || "-",
"--API_KEY_ARN": props.config.chat.apiInference.apiKey || "-",
"--RES_BUCKET": this.glueResultBucket.bucketName,
"--S3_BUCKET.$": "$.s3Bucket",
"--S3_PREFIX.$": "$.s3Prefix",
Expand Down
237 changes: 0 additions & 237 deletions source/lambda/intention/aos/sm_utils.py

This file was deleted.

Binary file modified source/lambda/job/dep/dist/llm_bot_dep-0.1.0-py3-none-any.whl
Binary file not shown.
35 changes: 31 additions & 4 deletions source/portal/src/pages/chatbot/ChatBot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ interface ChatBotProps {
historySessionId?: string;
}

const isValidUrl = (url: string): boolean => {
try {
new URL(url);
return url.startsWith('http://') || url.startsWith('https://');
} catch {
return false;
}
};

const isValidArn = (arn: string): boolean => {
// AWS Global and China ARN patterns
// arn:aws:secretsmanager:region:account-id:secret:name
// arn:aws-cn:secretsmanager:region:account-id:secret:name
const arnPattern = /^arn:aws(?:-cn)?:secretsmanager:[a-z0-9-]+:\d{12}:secret:.+$/;
return arnPattern.test(arn);
};

const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
const { historySessionId } = props;
// const localScenario = localStorage.getItem(MODEL_TYPE);
Expand Down Expand Up @@ -794,8 +811,13 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
<Input
value={apiEndpoint}
onChange={({ detail }) => {
setApiEndpointError('');
setApiEndpoint(detail.value);
const value = detail.value;
if (value === '' || isValidUrl(value)) {
setApiEndpointError('');
} else {
setApiEndpointError('Invalid url, please type in a valid HTTPS or HTTP url');
}
setApiEndpoint(value);
}}
placeholder="https://api.example.com/v1"
/>
Expand All @@ -809,8 +831,13 @@ const ChatBot: React.FC<ChatBotProps> = (props: ChatBotProps) => {
<Input
value={apiKeyArn}
onChange={({ detail }) => {
setApiKeyArnError('');
setApiKeyArn(detail.value);
const value = detail.value;
if (value === '' || isValidArn(value)) {
setApiKeyArnError('');
} else {
setApiKeyArnError('Invalid ARN, please type in a valid secret ARN from AWS Secrets Manager');
}
setApiKeyArn(value);
}}
placeholder="arn:aws:secretsmanager:region:account:secret:name"
/>
Expand Down

0 comments on commit 6f3f74d

Please sign in to comment.