♻️ (Prompt.py): refactor build_prompt method by simplifying the code and separating concerns
This commit is contained in:
parent
89f5df05e6
commit
f5a150aa13
1 changed files with 4 additions and 3 deletions
|
|
@ -20,8 +20,9 @@ class PromptComponent(Component):
|
|||
async def build_prompt(
|
||||
self,
|
||||
) -> Message:
|
||||
kwargs = {k: v for k, v in self._arguments.items() if k != "template"}
|
||||
prompt = await Message.from_template_and_variables(self.template, kwargs)
|
||||
prompt_message = Message(text=prompt.format_text(), **kwargs)
|
||||
prompt = await Message.from_template_and_variables(**self._arguments)
|
||||
kwargs = self._arguments.copy()
|
||||
kwargs["text"] = prompt.format_text()
|
||||
prompt_message = Message(**kwargs)
|
||||
self.status = prompt_message
|
||||
return prompt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue