import { PromptTemplate } from "@langchain/core/prompts"; import { SystemInstruction } from "./system-instruction"; export class MultiAttemptTemplate extends SystemInstruction { instruction = `## Objective: Determine if offering to generate a support ticket would be beneficial for the user. ## Instructions: - Analyze the chat history for patterns of repeated user questions. This includes identifying: - Criteria 1: Similar wording or phrasing across questions. ## Offer to generate a support ticket if: - There are at least 3 instances that meets Criteria 1 in the chat history ## Explain your rationale step by step following this flow: 1. List out the issues that meets Criteria 1 2. Compare if the number of repeated issues meets at least 3 instances 3. Determine if support should be offered ## Response Format: JSON {{ "reoccurringIssue": string, "numberTimesMentioned": string, "rationale": string, "offerSupport": "true" | "false" }} {examples} ## Chat History: {chatHistory} `; public get getInstruction(): PromptTemplate { const prompt = new PromptTemplate({ template: this.instruction, inputVariables: ["chatHistory", "examples"], }); return prompt; } }