Skip to content

Passing Conversational Context

Overview

What is it?

  • Context refers to additional information passed through the API or session history that helps seek better understand the user's needs and provide more relevant answers. It can include previous questions, user preferences, or relevant data from earlier in the conversation.

Why is it important?

  • Providing context improves the accuracy and relevance of the responses generated by Watsonx Assistant or NeuralSeek, as it allows the system to retain information from prior interactions and provide more personalized or situation-specific answers.

How does it work?

  • After a user's input is processed, the context can be carried over through the lastTurn parameter or Session History in the API request, enabling the system to maintain a coherent conversation by referring to previously shared details or refining queries based on earlier interactions.

Passing Conversational Context with watsonx Assistant

In watsonx Assistant, we can use the Session History variable to pass it to the options.lastTurn of NeuralSeek.

  1. Make sure a NeuralSeek Extension is already set up for watsonx Assistant to use it.
  2. Select the created NeuralSeek Extension, choose the 'Seek an answer from NeuralSeek' operation, and set the question parameter with the query_text session variable.

extension_config

  1. Display the 'Optional parameters' list.

optional_params

  1. Look for the options.lastTurn parameter and set it to Session History in the 'Assistant Variables' dropdown.

session_history

  1. Finally, hit 'Apply' and the configured extension will look like this. Remember to save the action.

configured_extension

  1. You can attempt a first question, such as "How can NeuralSeek help businesses in different industries with Gen AI?" in the chatbot preview.

first_attempt

  1. For a second attempt, try asking a follow-up question related to the first one. NeuralSeek will use the lastTurn parameter to infer the context of your intent.

context_attempt

Passing Conversational Context via API

The lastTurn parameter allows NeuralSeek API to incorporate the context of a previous conversation when generating responses. This is especially useful when a sequence of related questions or follow-ups is asked, as it helps NeuralSeek understand the progression of the conversation.

  1. Navigating to the 'Integrate' tab within NeuralSeek's interface. There we will be using the 'API' menu item.
  2. Send a request to the /seek endpoint. The lastTurn field should be an empty structure, since there is no prior context to reference. For example:
{
  "question": "How NeuralSeek can help businesses in different industries with Gen AI?",
  "options": {
    "lastTurn": [
      {
        "input": "",
        "response": ""
      }
    ]
  }
}

The answer will look like the one below. We should keep this answer value and the current user question for our next request.

{
  "answer": "NeuralSeek can help your business harness the power of generative AI. Our no-code platform connects to large language models and your company's data, making it much easier to deploy AI-powered solutions like virtual agents, content gen eration, and more. With NeuralSeek, you can create an AI agent, connect it to your knowledge base, and quickly generate intents and responses to automate customer support and share information with employees. This can enhance customer experiences and boost internal productivity across various functions. NeuralSeek is especially valuable for Fortune 500 companies looking to streamline their operations with AI. We've already partnered with multiple Fortune 500 businesses to help them rapidly implement AI without the typical complexity. I'd encourage you to explore some of these resources to learn more about how NeuralSeek can drive results in your industry: - Understanding NeuralSeek and Its Business Applications: https://ceoweekly.com/neuralseek-wh y-businesses-need-more-than-gen-ai-chatbots/ - NeuralSeek: The Future of AI Integration for Fortune 500 Companies: https://11mr eporter.com/posts/neuralseek-the-future-of-ai-integration-for-fortune-500-companies/"
}
  1. Send a second request. The lastTurn field should contain now the input (the previous question) and the corresponding response from NeuralSeek. This enables the API to consider the prior exchange and provide a more context-aware answer.

Example of a follow-up request with context:

{
  "question": "What about a pharmaceutical business?",
  "options": {
    "lastTurn": [
      {
        "input": "How NeuralSeek can help businesses in different industries with Gen AI?",
        "response": "NeuralSeek can help your business harness the power of generative AI. Our no-code platform connects to large language models and your company's data, making it much easier to deploy AI-powered solutions like virtual agents, content gen eration, and more. With NeuralSeek, you can create an AI agent, connect it to your knowledge base, and quickly generate intents and responses to automate customer support and share information with employees. This can enhance customer experiences and boost internal productivity across various functions. NeuralSeek is especially valuable for Fortune 500 companies looking to streamline their operations with AI. We've already partnered with multiple Fortune 500 businesses to help them rapidly implement AI without the typical complexity. I'd encourage you to explore some of these resources to learn more about how NeuralSeek can drive results in your industry: - Understanding NeuralSeek and Its Business Applications: https://ceoweekly.com/neuralseek-wh y-businesses-need-more-than-gen-ai-chatbots/ - NeuralSeek: The Future of AI Integration for Fortune 500 Companies: https://11mr eporter.com/posts/neuralseek-the-future-of-ai-integration-for-fortune-500-companies/"
      }
    ]
  }
}

In this follow-up request, the lastTurn provides context by including the previous question about generative AI and its response. This helps NeuralSeek better understand and address the new question about the pharmaceutical business in light of the prior exchange.

{
  "answer": "The pharmaceutical industry is a complex and highly regulated sector that discovers, develops, produces, and markets drugs for use as medications to be administered to patie nts. It's one of the fastest-growing economic sectors worldwide with sales exceeding $1 trillion, as a pharmaceutical business, you likely face challenges around drug development, clinical trials, regulatory compliance, patents, and commercialization. Utilizing AI and analytics at scale could help accelerate innovation and time-to-market for new therapies. NeuralSeek's no-code AI platform could enable your pharmaceutical company to:  - Automate customer support and medical information sharing - Generate content like scientific publications and regulatory documents - Streamline drug discovery and clinical trial processes - Personalize HCP and patient engagement  - Optimize supply chain and manufacturing operations. By connecting NeuralSeek to your company's proprietary data and systems, you can rapidly deploy AI solutions tailored to your specific needs and workflows as a pharma business. This can drive efficiencies, reduce costs, and ultimately help bring life-saving treatments to patients faster. I'd suggest checking out these resources to dive deeper into AI use cases fo r_pharma:  - The future of the pharmaceutical industry: https://www2.deloitte.com/us/en/insights/industry/health-care/future-of-pharmaceutical-industry.html - Pharma trends 2824: Sha ping the future landscape: https://www.zs.com/insights/trends-shaping-pharmaceutical-landscape-2824-and-beyond Let me know if you have any other questions!",
}