-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBedrock-Kb.yml
98 lines (86 loc) · 3.19 KB
/
Bedrock-Kb.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
AWSTemplateFormatVersion: 2010-09-09
Description: 'Serverless RAG Q&A application using Knowledge Base , Agents, Opensearch Serverless'
Parameters:
KnowledgeBaseName:
Default: rag-demo-kb
Type: String
Description: The name of the knowledge base.
KnowledgeBaseDescription:
Default: Answer based only on information contained in knowledge base.
Type: String
Description: The description of the knowledge base.
AmazonBedrockExecutionRoleForKnowledgeBasearn:
Type: String
Description: Execution Role for Knowledge Base Arn.
AgentName:
Default: rag-demo-agent
Type: String
Description: The name of the agent.
AOSSIndexName:
Default: rag-bedrock-index
Type: String
Description: Name of the vector index in the Amazon OpenSearch Service Serverless (AOSS) collection. You can get the name from the output section of the previous stack
DataSource:
Type: String
Description: S3 bucket name from the previous stack.
S3BucketArn:
Type: String
Description: S3 bucket arn from the previous stack.
CollectionArn:
Type: String
Description: Collection Arn from the previous stack.
Resources:
KnowledgeBaseWithAoss:
Type: AWS::Bedrock::KnowledgeBase
Properties:
Name: !Ref KnowledgeBaseName
Description: !Ref KnowledgeBaseDescription
RoleArn: !Ref AmazonBedrockExecutionRoleForKnowledgeBasearn
KnowledgeBaseConfiguration:
Type: "VECTOR"
VectorKnowledgeBaseConfiguration:
EmbeddingModelArn: !Sub "arn:${AWS::Partition}:bedrock:${AWS::Region}::foundation-model/cohere.embed-english-v3"
StorageConfiguration:
Type: "OPENSEARCH_SERVERLESS"
OpensearchServerlessConfiguration:
CollectionArn: !Ref CollectionArn
VectorIndexName: !Ref AOSSIndexName
FieldMapping:
VectorField: "vector"
TextField: "text"
MetadataField: "metadata"
SampleDataSource:
Type: AWS::Bedrock::DataSource
Properties:
KnowledgeBaseId: !Ref KnowledgeBaseWithAoss
Name: !Ref DataSource
DataSourceConfiguration:
Type: "S3"
S3Configuration:
BucketArn: !Ref S3BucketArn
# AmazonBedrockExecutionRoleForAgentsQA:
# Type: AWS::IAM::Role
# Properties:
# RoleName: AmazonBedrockExecutionRoleForAgents
# AssumeRolePolicyDocument:
# Statement:
# - Effect: Allow
# Principal:
# Service: bedrock.amazonaws.com
# Action: sts:AssumeRole
# ManagedPolicyArns:
# - arn:aws:iam::aws:policy/AmazonBedrockFullAccess
# AgentResource:
# Type: AWS::Bedrock::Agent
# Properties:
# AgentName: !Ref AgentName
# AgentResourceRoleArn: !GetAtt AmazonBedrockExecutionRoleForAgentsQA.Arn
# AutoPrepare: true
# FoundationModel: "anthropic.claude-v2"
# Instruction: "You are a Q&A bot to answer questions on Amazon SageMaker"
# Description: "Description is here"
# IdleSessionTTLInSeconds: 900
# KnowledgeBases:
# - KnowledgeBaseId: !Ref KnowledgeBaseWithAoss
# Description: !Ref KnowledgeBaseDescription
# KnowledgeBaseState: ENABLED