mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
d069c668f8
Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: chenhe <guchenhe@gmail.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn>
11 lines
387 B
Python
11 lines
387 B
Python
from core.prompt.prompt_template import PromptTemplateParser
|
|
|
|
|
|
class PromptBuilder:
|
|
@classmethod
|
|
def parse_prompt(cls, prompt: str, inputs: dict) -> str:
|
|
prompt_template = PromptTemplateParser(prompt)
|
|
prompt_inputs = {k: inputs[k] for k in prompt_template.variable_keys if k in inputs}
|
|
prompt = prompt_template.format(prompt_inputs)
|
|
return prompt
|