The follow-up endpoint allows you to ask additional questions within an existing search session, maintaining conversation context and chat history. This enables multi-turn conversations where each question builds on previous answers.
The follow-up question or statement. Can reference previous answers using pronouns or context (e.g., “Tell me more about that”, “What are the alternatives?”).
Unlike the initial search response, follow-up responses do not include sessionId (use the same one for subsequent questions), relatedQuestions, or images.
{ "summary": "<h2>Types of Machine Learning</h2>\n<p>The three main types are:</p>\n<h3>Supervised Learning</h3>\n<p>The algorithm learns from labeled training data, where both input and desired output are provided...</p>\n<h3>Unsupervised Learning</h3>\n<p>The algorithm finds patterns in unlabeled data...</p>\n<h3>Reinforcement Learning</h3>\n<p>The algorithm learns through trial and error...</p>", "sources": [ { "title": "Types of Machine Learning - Stanford", "url": "https://cs.stanford.edu/ml-types", "snippet": "The three main types are: Supervised Learning Unsupervised Learning Reinforcement Learning" }, { "title": "Machine Learning Categories Explained", "url": "https://example.com/ml-categories", "snippet": "The algorithm learns from labeled training data" } ]}
Session IDs are 6-7 character alphanumeric strings generated using:
Math.random().toString(36).substring(7)
Example: k7x9m2a, abc123, x5y8z1
Important: Sessions are stored in memory and will be lost when the server restarts. For production use, implement persistent session storage (Redis, database, etc.).
Initial: "What is photosynthesis?"Answer: [Explanation of photosynthesis]Follow-up 1: "What are the two main stages?"Context: Model understands "two main stages" refers to photosynthesisAnswer: [Light-dependent and light-independent reactions]Follow-up 2: "Where does the first one occur?"Context: Model understands "first one" means light-dependent reactionsAnswer: [Thylakoid membranes in chloroplasts]
// Good: Store session ID for the entire conversationconst session = { id: searchData.sessionId, topic: 'quantum computing' };localStorage.setItem('currentSession', JSON.stringify(session));
// Good: Reference previous contextconst questions = [ "What is blockchain?", "How does it ensure security?", // "it" refers to blockchain "What are the main types?", // "types" of blockchain "Explain the first one" // "first one" references the types];// Less effective: Repeat full contextconst questions = [ "What is blockchain?", "How does blockchain ensure security?", "What are the main types of blockchain?", "Explain proof of work in blockchain"];
# Deep dive into a topicInitial: "What is CRISPR gene editing?"Follow-up 1: "What are the ethical concerns?"Follow-up 2: "How is it being used in medicine?"Follow-up 3: "What are the limitations?"
Initial: "Explain how neural networks work"Follow-up: "Can you explain backpropagation in simpler terms?"Follow-up: "What's an example with actual numbers?"
Initial: "Overview of renewable energy"Follow-up: "Tell me more about solar energy specifically"Follow-up: "What are the latest improvements in solar panel efficiency?"Follow-up: "Which companies are leading in this technology?"