🐛 fix(utils.py): add support for initializing class objects with a template parameter
This commit is contained in:
parent
dd6d510be3
commit
94003cf39a
1 changed files with 3 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ from typing import Any, Dict, List
|
|||
import orjson
|
||||
from langchain.agents import ZeroShotAgent
|
||||
from langchain.schema import BaseOutputParser, Document
|
||||
|
||||
from langflow.services.database.models.base import orjson_dumps
|
||||
|
||||
|
||||
|
|
@ -16,6 +17,8 @@ def handle_node_type(node_type, class_object, params: Dict):
|
|||
prompt = instantiate_from_template(class_object, params)
|
||||
elif node_type == "ChatPromptTemplate":
|
||||
prompt = class_object.from_messages(**params)
|
||||
elif hasattr(class_object, "from_template") and params.get("template"):
|
||||
prompt = class_object.from_template(template=params.pop("template"))
|
||||
else:
|
||||
prompt = class_object(**params)
|
||||
return params, prompt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue