Spaces:
Build error
Build error
File size: 1,089 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 30 |
"""
Generates a formatted prompt for completing the abstract of a paper.
Args:
usr_input (str): The user input containing the title and part of the abstract.
Expected format:
"Title: <title>\nAbstract: <abstract>"
template (dict): A dictionary containing the template for the prompt.
Expected format:
{"prompt_input": "<template_string>"}
The template string should contain placeholders for
'instruction' and 'input'.
Returns:
str: A formatted string with the instruction and the input embedded in the template.
"""
def abs_completion(usr_input, template, has_predefined_template=False):
instruction = "Please complete the abstract of a paper."
if has_predefined_template:
res = [
{"role": "system", "content": instruction},
{"role": "user", "content": usr_input},
]
else:
res = template["prompt_input"].format(instruction=instruction, input=usr_input)
return res
|