0
0
LangChainframework~10 mins

Why conversation history improves RAG in LangChain - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add conversation history to the retriever query.

LangChain
query = [1] + ' ' + user_input
Drag options to blanks, or click blank then click option'
Aconversation_history
Bempty_string
Cirrelevant_data
Drandom_text
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated or empty strings instead of conversation history.
Not including any context in the query.
2fill in blank
medium

Complete the code to update the conversation history after each user input.

LangChain
conversation_history = conversation_history + '\nUser: ' + [1]
Drag options to blanks, or click blank then click option'
Aempty_string
Bsystem_response
Cuser_input
Dretriever_output
Attempts:
3 left
💡 Hint
Common Mistakes
Appending system responses instead of user inputs.
Not updating the conversation history at all.
3fill in blank
hard

Fix the error in the code that combines conversation history and user input for retrieval.

LangChain
retrieval_query = [1] + ' ' + user_input
Drag options to blanks, or click blank then click option'
Aretriever_output
Bconversation_history
Csystem_response
Dempty_string
Attempts:
3 left
💡 Hint
Common Mistakes
Using system responses or empty strings instead of conversation history.
Forgetting to include conversation history in the retrieval query.
4fill in blank
hard

Fill both blanks to create a function that updates conversation history and prepares the retrieval query.

LangChain
def update_and_query(user_input, [1]):
    [2] += '\nUser: ' + user_input
    retrieval_query = [2]
    return retrieval_query, [2]
Drag options to blanks, or click blank then click option'
Aconversation_history
Bsystem_response
Duser_input
Attempts:
3 left
💡 Hint
Common Mistakes
Using system_response instead of conversation_history.
Mixing up parameter and variable names.
5fill in blank
hard

Fill all three blanks to implement a retrieval-augmented generation step using conversation history.

LangChain
def rag_step(user_input, [1]):
    [2] += '\nUser: ' + user_input
    retrieval_query = [2]
    retrieved_docs = retriever.retrieve([3])
    return retrieved_docs, [2]
Drag options to blanks, or click blank then click option'
Aconversation_history
Cretrieval_query
Duser_input
Attempts:
3 left
💡 Hint
Common Mistakes
Passing user_input directly to retriever instead of the combined query.
Not updating conversation history before retrieval.