File size: 783 Bytes
eaa3d8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
import os
from typing import List, Optional


def build_summarizer_prompt(
    prompt_template:str,
    input_text_list:List[str],
    chat_mode:Optional[str] = None) -> str:
    
    """_summary_
    chat_mode(str) : 'hf-chat', 'kullm', 'None'

    Returns:
        _type_: _description_
    """
    
    if os.path.isfile(prompt_template):
        with open(prompt_template,'r') as f:
            prompt_template = f.read() 
    else:
        pass
    
    # ์˜ˆ์™ธ์ฒ˜๋ฆฌ ํ•„์š”
    assert isinstance(prompt_template, str)
    
    prompt = prompt_template.format(*input_text_list)
    
    if chat_mode == "hf-chat":
        prompt = _get_hf_chat_template().format(prompt)
    elif chat_mode == "kullm":
        prompt = _get_kullm_template().format(prompt)
    
    return prompt