🐛 fix(vertex/base.py): add artifacts attribute to Vertex class to store additional data
🐛 fix(vertex/base.py): update instantiation logic to handle tuple result from loading.instantiate_class() 🐛 fix(loading.py): update return value of instantiate_prompt() to return a tuple of prompt and format_kwargs The Vertex class now has a new attribute called artifacts, which is a dictionary used to store additional data related to the vertex. The instantiation logic in the Vertex class has been updated to handle the case where loading.instantiate_class() returns a tuple containing the built object and additional artifacts. The loading.instantiate_prompt() function now returns a tuple containing the prompt and format_kwargs. These changes fix issues related to storing and handling additional data in the vertex and loading modules.
This commit is contained in:
parent
78ffad4c85
commit
03349bf999
2 changed files with 9 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ class Vertex:
|
|||
self._parse_data()
|
||||
self._built_object = None
|
||||
self._built = False
|
||||
self.artifacts: Dict[str, Any] = {}
|
||||
|
||||
def _parse_data(self) -> None:
|
||||
self.data = self._data["data"]
|
||||
|
|
@ -195,11 +196,17 @@ class Vertex:
|
|||
# and return the instance
|
||||
|
||||
try:
|
||||
self._built_object = loading.instantiate_class(
|
||||
result = loading.instantiate_class(
|
||||
node_type=self.vertex_type,
|
||||
base_type=self.base_type,
|
||||
params=self.params,
|
||||
)
|
||||
# Result could be the _built_object or
|
||||
# (_built_object, dict) tuple
|
||||
if isinstance(result, tuple):
|
||||
self._built_object, self.artifacts = result
|
||||
else:
|
||||
self._built_object = result
|
||||
except Exception as exc:
|
||||
raise ValueError(
|
||||
f"Error building node {self.vertex_type}: {str(exc)}"
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ def instantiate_prompt(node_type, class_object, params):
|
|||
if format_kwargs:
|
||||
prompt = prompt.partial(**format_kwargs)
|
||||
|
||||
return prompt
|
||||
return prompt, format_kwargs
|
||||
|
||||
|
||||
def instantiate_tool(node_type, class_object, params):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue