-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (35 loc) · 1.54 KB
/
main.py
File metadata and controls
44 lines (35 loc) · 1.54 KB
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
from dotenv import load_dotenv
from rag.core import (
build_system_instructions,
Config,
generate_answer,
initialize_bedrock_client,
initialize_kendra_client,
retrieve_context,
)
def main() -> None:
# Load environment variables from .env file if present
load_dotenv()
# Load and validate settings structure
config = Config.from_env()
# Initialize AWS clients
kendra_client = initialize_kendra_client()
bedrock_client = initialize_bedrock_client()
# Bank of sample questions
answer = "Follow the lab directions to explore this code."
question = "Can I return a leather journal if I had my initials embossed on it?"
# question = "What paper types are best for ballpoint pens?"
# question = "What paper types are best for glass quill pens?"
# question = "How much wood could a woodchuck chuck if a woodchuck could chuck wood?"
# question = "What paper could provide a pleasing mouth feel for a woodchuck to chew on while chucking wood?"
# question = "What can I make for dinner on a budget?"
# Retrieve relevant context from Kendra index
# retrieved_text = retrieve_context(kendra_client, config, question)
# Build the system prompt to include with the request to Bedrock
# system_instructions = build_system_instructions(retrieved_text)
# Get Bedrock to answer the question, providing the relevant context
# answer = generate_answer(bedrock_client, config, system_instructions, question)
# Print the answer
print(answer)
if __name__ == "__main__":
main()