File size: 987 Bytes
908351f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Generate the abstract of a paper based on its introduction section.

Args:
    usr_prompt (str): The user-provided prompt containing the introduction section of the paper.
    template (dict): A dictionary containing the template for generating the abstract.
    context_window (int): The maximum length of the context window for the prompt input.

Returns:
    str: The generated abstract based on the introduction section.
"""


def intro_2_abs(usr_prompt, template, context_window, has_predefined_template=False):
    instruction = "Please generate the abstract of paper based on its introduction section."

    # Reduce it to make it fit
    prompt_input = usr_prompt[:int(context_window*2)]

    if has_predefined_template:
        res = [
            {"role": "system", "content": instruction},
            {"role": "user", "content": prompt_input},
        ]
    else:
        res = template["prompt_input"].format(instruction=instruction, input=prompt_input)

    return res