✨ feat(loading.py): add support for new prompt templates in instantiate_prompt function
The config.yaml file has been updated to include new prompt templates. In types.py, the input_variables list was not being cleared when prompt or messages were present, which has been fixed. The instantiate_prompt function in loading.py has been updated to support the new prompt templates. 🔀 chore(config): add new prompt templates to config.yaml 🐛 fix(types.py): fix input_variables not being cleared when prompt or messages are present
This commit is contained in:
parent
d3a2367932
commit
8107f9e332
3 changed files with 29 additions and 5 deletions
|
|
@ -97,6 +97,19 @@ def instantiate_prompt(node_type, class_object, params):
|
|||
if "tools" not in params:
|
||||
params["tools"] = []
|
||||
return ZeroShotAgent.create_prompt(**params)
|
||||
if "MessagePromptTemplate" in node_type:
|
||||
# Then we only need the template
|
||||
from_template_params = {
|
||||
"template": params.pop("prompt", params.pop("template", ""))
|
||||
}
|
||||
|
||||
if not from_template_params.get("template"):
|
||||
raise ValueError("Prompt template is required")
|
||||
return class_object.from_template(**from_template_params)
|
||||
|
||||
if node_type == "ChatPromptTemplate":
|
||||
return class_object.from_messages(**params)
|
||||
|
||||
return class_object(**params)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue