def get_prompt()

in tools/genai-prod-catalog-enrichment/genai_helper.py [0:0]


def get_prompt(context, task, error="", product_name=""):
    """Gets the prompt for the given task."""

    # FAQ's, ISQ's constants

    faq_json_format = """{
        "catalogue_faqs": [
            {"question": "What is the size of the paper
            napkin produced by this machine?",
            "answer": "The paper napkin produced by
            this machine is 30 X 30 cm."},
            {"question": "What is the speed of this machine?",
            "answer": "This machine can produce 2,50,000 pieces in 8 hours."},
            {"question": "How many colors can this machine print?",
            "answer": "This machine can print up to 2 colors."},
            {"question": "What is the weight of this machine?",
            "answer": "This machine weighs approximately 2500 kgs."},
            {"question": "How many people are required
            to operate this machine?",
            "answer": "This machine requires one
            operator and one helper to operate."},
            {"question": "What type of raw material does this machine use?",
            "answer": "This machine uses tissue paper with a gsm of 12 to 30."}
        ]
    }"""

    sample_json_response = {

        "product_name": [
            "SINGLE SIZE PAPER NAPKIN MACHINE",
        ],
        "specifications": [
            {
                "SINGLE SIZE PAPER NAPKIN MACHINE": {
                    "Size": "30 X 30 CM",
                    "No of Printing": "As Per Requirement",
                    "Embossing Unit": "As Per Requirement",
                    "Motor": [
                        "3hp motor with variable"
                        " AC drive with VDF (Variable frequency drive)",
                        "1hp motor (AC)"
                    ],
                    "Speed": "2,50,000 PIECES / 8 HOURS",
                    "Weight": "2500 kgs (approx)",
                    "Man Power": "One operator & One helper",
                    "Raw Material": "Tissue paper 12 to 30 gsm",
                    "Counting": "digital",
                    "PRICE WITHOUT PRINT": "4,50,000",
                    "1 COLOUR PRINT": "5,75,000",
                    "2 COLOUR PRINT": "6,25,000"
                }}],
        "confidence_score": 0.8
    }

    company_details_format = {
        "company_details": {
            "company_name": "Global Conversion Machines",
            "company_description": "",
            "company_phone_number": {
                "SALES TEAM": "+ 91 958 215 2344",
                "MARKETING TEAM": "+ 91 874 482 8924",
                "SERVICE TEAM": "+ 91 888 291 3467"
            },
            "company_email": "globalconversionmachines@gmail.com",
            "company_website": "",
            "company_social_handles": {
                "twitter": "@globalcmachines",
                "instagram": "@globalconversionmachines",
                "youtube": "Global Conversion Machines"
            },
            "company_address": ""
        }
    }

    # blocked_response = get_blocked_response_template()
    malformed_json = """
    {
        'product_name': ['Acrylic Body Rotameter'],
        'specifications': [
            {'Acrylic Body Rotameter': {
                'Metering Tube': 'Solid Acrylic Block',
                'Body': 'Imported transparent acrylic block',
                'Wetted Parts': 'M.S. / S.S. / P.P. / Teflon',
                'End Connection': 'S.S. 304/316/PVC/PP/MS',
                'Scale': 'Engraved on body',
                'Packing': 'Neoprene / Teflon / Silicon',
                'Model': 'JP/ABR',
                'Temperature': 'Max 60C',
                'Pressure': 'Max 25 Kg/Cm',
                'Available sizes': '1/8 to 100 NB',
                'Flow Ranges': '2 to 60,000 LPH of water at
                ambient temperature and 0.1 to 750 Nm/hr of air at NTP',
                'End Connection': 'Screwed / Flanged / Hose Nipple',
                'Orientation': 'Bottom Top / Rear Rear',
                'Accuracy': '2% of FSD',
                'Accessories': 'High & low flow alarms and 4-20
                mA output on your request',
                'THREDED CONNECTION': {
                    'Line Size Flow rate (BSP CONNECTION)':
                    'Water at amb.temp. in LPH',
                    'Minimum LPH': 'Maximum LPH',
                    'BSP 6': '60',
                    'BSP 200': '2000',
                    'BSP 400': '4000',
                    '1 BSP': '500',
                    '1.5 BSP': '1200',
                    '2 BSP': '2500'
                    }
                }
             },
            'confidence_score': 0.8
            }
    """

    fixed_json = """
    {
    "product_name": [
    "Acrylic Body Rotameter"
    ],
    "specifications": [
    {
    "Acrylic Body Rotameter": {
    "Metering Tube": "Solid Acrylic Block",
    "Body": "Imported transparent acrylic block",
    "Wetted Parts": "M.S. / S.S. / P.P. / Teflon",
    "End Connection": "S.S. 304/316/PVC/PP/MS",
    "Scale": "Engraved on body",
    "Packing": "Neoprene / Teflon / Silicon",
    "Model": "JP/ABR",
    "Temperature": "Max 60C",
    "Pressure": "Max 25 Kg/Cm",
    "Available sizes": "1/8 to 100 NB",
    "Flow Ranges": "2 to 60,000 LPH of water
    at ambient temperature and 0.1
    to 750 Nm/hr of air at NTP",
    "End Connection": "Screwed / Flanged / Hose Nipple",
    "Orientation": "Bottom Top / Rear Rear",
    "Accuracy": "2% of FSD",
    "Accessories": "High & low flow alarms and 4-20 mA output on your request",
    "THREDED CONNECTION": {
    "Line Size Flow rate (BSP CONNECTION)": "Water at amb.temp. in LPH",
    "Minimum LPH": "Maximum LPH",
    "BSP 6": "60",
    "BSP 200": "2000",
    "BSP 400": "4000",
    "1 BSP": "500",
    "1.5 BSP": "1200",
    "2 BSP": "2500"
    }
    }
    }
    ],
    "confidence_score": 0.9
    }
    """

    non_woven_bag = {
        "tags": ["Industrial Machine", "Bag Making Machine"],
        "suggested_category": "Non Woven Bag Making Machine"
    }

    toilet_roll_machine = {
        "tags": ["Industrial Machine",
                 "Paper Roll Machine", "Toilet Roll Machine"],
        "suggested_category": "Toilet Roll Making Machine"
    }

    malformed_faq = """
    {
        "catalogue_faqs": [
            {"question": "What is the purpose of this diagram?",
            "answer": "This diagram shows the piping and wiring
            schematic for an AO Smith heat pump water heater."},
            {"question": "What are the different components
            shown in the diagram?",
            "answer": "The diagram shows the following components:
            1)    Hot water to rooms
            2)    Tank temp sensor
            3)    Hot water outlet
            4)    Flow switch
            5)    Vibration pads
            6)    Return water from rooms
            7)    Cold water inlet to heat pump
            8)    FFL note"},
            {"question": "What are the different
            steps involved in the operation of this system?",
            "answer": "The steps involved in the
            operation of this system are as follows:
            1)    Cold water enters the heat pump through the cold water inlet.
            2)    The heat pump heats the water
            and sends it to the hot water tank.
            3)    The hot water is then distributed to the
            rooms through the hot water to rooms pipes.
            4)    The return water from the rooms is then sent back to the
            heat pump through the return water from rooms pipes.
            5)    The process repeats itself."},
            {"question": "What are some of the important safety precautions
            that should be taken when working on this system?",
            "answer": "Some of the important safety precautions
            that should be taken when working on this system include:
            1)    Always turn off the power to the system before working on it.
            2)    Be sure to use proper safety equipment,
            such as gloves and eye protection.
            3)    Never work on the system while it is hot.
            4)    Be aware of the location of
            all of the components in the system.
            5)    If you are unsure about anything,
            always consult a qualified professional."}
        ]
    }
    """

    fixed_faq = """
    {"catalogue_faqs": [{"question": "What is the purpose of this diagram?",
    "answer": "This diagram shows the piping and wiring schematic
    for an AO Smith heat pump water heater."},
    {"question": "What are the different components shown in the diagram?",
    "answer": "The diagram shows the following
    components:\n1) Hot water to rooms\n2) Tank temp sensor\n
    3) Hot water outlet\n4) Flow switch\n
    5) Vibration pads\n6) Return water from rooms\n
    7) Cold water inlet to heat pump\n8) FFL note"},
    {"question": "What are the different
     steps involved in the operation of this system?",
    "answer": "The steps involved in the
    operation of this system are as follows:\n
    1) Cold water enters the heat pump through the cold water inlet.\n
    2) The heat pump heats the water and sends it to the hot water tank.\n
    3) The hot water is then distributed to the
    rooms through the hot water to rooms pipes.\n
    4) The return water from the rooms is then
    sent back to the heat pump through the return water from rooms pipes.\n
    5) The process repeats itself."},
    {"question": "What are some of the important
    safety precautions that should be taken when working on this system?",
    "answer": "Some of the important safety
    precautions that should be taken when working on this system include:\n
    1) Always turn off the power to the system before working on it.\n
    2) Be sure to use proper safety equipment,
    such as gloves and eye protection.\n
    3) Never work on the system while it is hot.\n
    4) Be aware of the location of all of the components in the system.\n
    5) If you are unsure about anything,
    always consult a qualified professional."}]}
    """

    # failed_faq = get_failed_faq_template()

    check_faq_prompt = f"""For the following text,
    examine if it contains a description,
    product specifications or features.
    If found, return a boolean response True.
     If not found, return a boolean response False.

    {context}"""

    faq_prompt = f"""Generate a list of frequently asked
    questions (FAQ) based only on the provided input.

    Extract the key points, common queries,
    and important details to create a concise
    and informative set of questions and
    answers that would provide clarity on this subject for readers.

    Return the output in JSON format.
    input: 02 SINGLE SIZE PAPER NAPKIN
    MACHINE Size: 30 X 30 CM No of Printing :
    As Per Requirement Embossing Unit:
    As Per Requirement Motor: 1) 3hp motor with variable
    AC drive with VDF (Variable frequency drive)
     2) 1hp motor (AC) Speed: 2,50,000 PIECES / 8 HOURS
    Weight: 2500 kgs (approx) Man Power: One operator &
    One helper Raw Material:
    Tissue paper 12 to 30 gsm Counting: digital Counting Band saw
     cutting with mauling sharping system PRICE WITHOUT PRINT : `4,50,000
     1 COLOUR PRINT : `5,75,000 2 COLOUR PRINT : `6,25,000
    output: {faq_json_format}

    input: {context}
    output:
    """

    check_specs_prompt = f"""For the following text, examine
    if it contains a product description, specifications
    or features. If found, return a boolean response True.
     If not found, return a boolean response False.

    {context}
    """

    product_specs_prompt = f"""Convert the following text into a
    product specifications JSON containing \"product_name\"
    and other \"specifications\".
    Also, add a \"confidence_score\" to the end of the JSON.

    input: 02 SINGLE SIZE PAPER NAPKIN MACHINE
     Size: 30 X 30 CM No of Printing : As Per Requirement Embossing Unit:
    As Per Requirement Motor: 1) 3hp
    motor with variable AC drive with VDF (Variable frequency drive)
    2) 1hp motor (AC) Speed: 2,50,000 PIECES / 8
    HOURS Weight: 2500 kgs (approx) Man Power: One operator &
    One helper Raw Material: Tissue paper 12 to
    30 gsm Counting: digital Counting Band saw
     cutting with mauling sharping system
     PRICE WITHOUT PRINT :
     `4,50,000 1 COLOUR PRINT :
     `5,75,000 2 COLOUR PRINT : `6,25,00
    output: {sample_json_response}

    input: {context}
    output:
    """

    company_details_prompt = f"""Convert the following
    text into a JSON containing company details.
    Ensure that the details extracted
    are based solely on the content of the
    following text and are as accurate as possible.

    input: CONTACT US COMPLETE MACHINE GLOBAL
    CONVERSION MACHINES SALES TEAM MARKETING
    TEAM SERVICE TEAM + 91 958 215 2344 + 91 874 482 8924 + 91 888 291 3467
     Email : globalconversionmachines@gmail.com
     Follow us on @ globalcmachines @
     globalconversionmachines Global Conversion Machines
    output: {company_details_format}

    input: {context}
    output:
    """

    fix_json_prompt = f"""Fix the error/malformation
    in the following JSON and ensure that you only return a valid JSON.

    Error: {error}

    input: {malformed_json}
    output: {fixed_json}

    input: {context}
    output:
    """

    tags_and_label_prompt = f"""Suggest some tags and
     a category for the given product name and
    description and convert it into JSON format.
    Ensure that the suggestions are based solely on the content of
    the text and are as accurate as possible.

    input: Product Name: Non Woven Bag Making Machine
    Product Description: 07 NON WOVEN BAG MAKING MACHINE Technical Specification
    Fabric Paper Tube Diameter: 2.75 -3 Inches
    Max Speed: 20 -120 Bags /min Bag Width: 3.9-32
    Inches Bag Height: 7.75-24mm Bottom Insert Size: 1.20-3.25 Inches
    Side Folding Size: 1.20-3.25 Inches
    Bag Thickness: 30-120g Power Supplier: 220v/380v Power: 12kw 15kw
    Overall Dimension (L*w*h): 7600*1900*2100mm Weight: 2200 Kg Air
    Compressor: 0.6-1.0 Mpa Unwinding Method: Magnetic Power Tension Control
     Unwinding Diameter: 1000 Mm Max.width Of
      Unwinding: 1300 Mm Correction Device: Photoelectric
     Epc System An Synchronous Rectification Motor 110w PRICE PRICE: ` 15,95,000
    output: {non_woven_bag}

    input: Product Name: Toilet Roll Machine
    Product Description: 04 TOILET ROLL MACHINE PRODUCT PRICE PRODUCTION TYPE
     1 4500 Rolls / 8 Hours Toilet Roll ` 4,75,000
     TYPE 2 9000 Rolls / 8 Hours Toilet Roll,
     ` 5,25,000 Kitchen Rolls ,
      Non Woven Cleaning Rolls,
      Hospital Bed Tissue Rolls.
      TYPE 3 17,000 Rolls /
      8 Hours Toilet Roll,
      `11,50,000 Kitchen Rolls,
      Non Woven Cleaning Rolls,
      Hospital Bed Tissue Rolls.
      TYPE 4 Any Customized Production Capacity
    output: {toilet_roll_machine}

    input: Product Name: {product_name}
    Product Description: {context}
    output:
    """

    fix_faq_json_prompt = f"""Fix the error/malformation in the following
    JSON and ensure that you only return a valid JSON.

    Error: {error}

    input: {malformed_faq}
    output: {fixed_faq}

    input: {context}
    output:
    """

    if task == "faq":
        return faq_prompt
    elif task == "specs":
        return product_specs_prompt
    elif task == "check_specs":
        return check_specs_prompt
    elif task == "company_details":
        return company_details_prompt
    elif task == "image_tags_and_labels":
        return tags_and_label_prompt
    elif task == "fix_json":
        return fix_json_prompt
    elif task == "fix_faq_json":
        return fix_faq_json_prompt
    else:
        return check_faq_prompt