import { PromptTemplate } from "@langchain/core/prompts"; import { SystemInstruction } from "./system-instruction"; export class RequireSupportTemplate extends SystemInstruction { instruction = `## Objective: Determine if support ticket is requested by the user. ## Instructions: - Analyze the chat history regarding if the user asks for support ticket or if user accepted the creation of support ticket that is offered by the assistant ## Determine if Support Ticket should get generated Generate Support Ticket is True if and only if one of the following conditions is met: * Condition 1: Did the user ask for a support ticket? * Condition 2: Did the user accept the offer for the creation support ticket by the assistant? ## Response Format: JSON {{ "userRequestedSupportTicket": "true" | "false", "userAcceptsOfferedSupportTicket": "true" | "false", "generateSupportTicket": "true" | "false" }} ## Examples Example ID: 1 Chat History: Assistant: "Yes, you can include expressions inside f-strings. For example: \`f'Total after tax: {{total * 1.1}} dollars'\`." User: "I want to talk to support agent" Response: {{ "userRequestedSupportTicket": "true", "userAcceptsOfferedSupportTicket": "false", "generateSupportTicket": "true" }} Example ID: 2 Chat History: Assistant: "Great question, would you like me to create a support ticket?" User: "Sure" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "true", "generateSupportTicket": "true" }} Example ID: 3 Chat History: Assistant: "To resolve the TypeScript error “Non-abstract class 'MultiAttemptTemplate' does not implement all abstract members of 'PromptTemplate'”, you need to ensure that the MultiAttemptTemplate class correctly implements the abstract members defined in the PromptTemplate class. The PromptTemplate class has an abstract member instruction which needs to be implemented in the derived class." User: "Can you help me submit a support ticket?" Response: {{ "userRequestedSupportTicket": "true", "userAcceptsOfferedSupportTicket": "false", "generateSupportTicket": "true" }} Example ID: 4 Chat History: Assistant: "Looks like I cannot resolve your issue. Would you like to file a support ticket?" User: "ok" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "true", "generateSupportTicket": "true" }} Example ID: 5 Chat History: Assistant: "I'm sorry, but I can't seem to resolve your problem. Would you like to file a support ticket?" User: "Yes" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "true", "generateSupportTicket": "true" }} Example ID: 6 Chat History: Assistant: "The ESLint rule @typescript-eslint/class-literal-property-style suggests that literals should be exposed using getters instead of directly as properties. To comply with this rule, you should define the instruction property as a getter method rather than a public instance variable." User: "I want to talk to support" Response: {{ "userRequestedSupportTicket": "true", "userAcceptsOfferedSupportTicket": "false", "generateSupportTicket": "true" }} Example ID: 7 Chat History: Assistant: "Unfortunately, I can't solve your issue. Would you like to open a support ticket?" User: "Alright" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "true", "generateSupportTicket": "true" }} Example ID: 8 Chat History: Assistant: "Unfortunately, I can't solve your issue. Would you like to open a support ticket?" User: "Alright" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "true", "generateSupportTicket": "true" }} Example ID: 9 Chat History: Assistant: "How can I help in "Data Science for Beginners"?" User: "What libaries are commonly used for Data Science?" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "false", "generateSupportTicket": "false" }} Example ID: 10 Chat History: Assistant: "To convert MultiAttemptExample objects to Record[] and ensure the chatHistory elements are not enclosed in {{}}, you need to transform each chatHistory entry to a string, then join them into a single string for the chatHistory field." User: "Getting this error: @typescript-eslint/no-require-imports" Response: {{ "userRequestedSupportTicket": "false", "userAcceptsOfferedSupportTicket": "false", "generateSupportTicket": "false" }} ## Chat History: {chatHistory} `; public get getInstruction(): PromptTemplate { try { const prompt = new PromptTemplate({ template: this.instruction, inputVariables: ["chatHistory"], }); return prompt; } catch (error) { if (error instanceof Error) { throw new Error(`Error creting prompt template ${error.message}`); } else { throw new Error(`Error creting prompt template`); } } } }