Complete the code to import the correct class for prompt templates in LangChain.
from langchain.prompts import [1]
The PromptTemplate class is used to create prompt templates in LangChain.
Complete the code to create two prompt templates for A/B testing with different greetings.
prompt_a = PromptTemplate(template="Hello, {" + [1] + "}! How can I help you?") prompt_b = PromptTemplate(template="Hi, {" + [1] + "}! What can I do for you?")
The variable name is commonly used to personalize prompts by inserting the user's name.
Fix the error in the code to select a prompt template randomly for A/B testing.
import random prompts = [prompt_a, prompt_b] selected_prompt = prompts[[1](0, 1)]
random.randint(0, 1) returns a random integer 0 or 1, which is used as an index to select a prompt.
Fill both blanks to create a dictionary that maps prompt names to their templates for easy access.
prompt_variations = { [1]: prompt_a, [2]: prompt_b }Using simple keys like "A" and "B" helps identify prompt variations clearly.
Fill all three blanks to complete the function that runs A/B testing by selecting a prompt and formatting it with a user name.
def run_ab_test(user_name): selected = prompt_variations[[1]] formatted_prompt = selected.[2]([3]=user_name) return formatted_prompt
The function selects prompt "B", calls format with the keyword argument name to personalize the prompt.