Project - Building a RAG Chatbot from Your Website Data using OpenAI and Langchain

23 / 26

Step 7: Making the chatbot user-interactive

Let's code the function to return LLM response!

INSTRUCTIONS
  1. Define a function get_response that generates a response based on the input question. It will take question, organization_name, organization_info, contact_info as input:

    def get_response(question, organization_name, organization_info, contact_info):
    
  2. Now write further code inside this function.

  3. Initialize chat_history. Here, we initialize chat_history as an empty string for this demonstration. But you can pass the conversation here:

    chat_history = ""
    
  4. Invoke/Run the chain we created and store the output in a variable response:

    chain = make_chain()
    response = chain({"question": question, "chat_history": chat_history,
                  "organization_name": organization_name, "contact_info": contact_info,
                  "organization_info": organization_info})
    
  5. response is a directory storing several values. We just need to return the 'answer'. Try exploring what all the response directory includes:

    return response['answer']
    
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...