fix: KeyError in Langchain Hub component (#4530)
* fix: KeyError in Langchain Hub component * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
1dfa160385
commit
be44183345
1 changed files with 3 additions and 1 deletions
|
|
@ -99,9 +99,11 @@ class LangChainHubPromptComponent(Component):
|
|||
template = self._fetch_langchain_hub_template()
|
||||
|
||||
# Get the parameters from the attributes
|
||||
original_params = {k.removeprefix("param_"): v for k, v in self._attributes.items()}
|
||||
params_dict = {param: getattr(self, "param_" + param, f"{{{param}}}") for param in template.input_variables}
|
||||
original_params = {k: v.text if hasattr(v, "text") else v for k, v in params_dict.items() if v is not None}
|
||||
prompt_value = template.invoke(original_params)
|
||||
|
||||
# Update the template with the new value
|
||||
original_params["template"] = prompt_value.to_string()
|
||||
|
||||
# Now pass the filtered attributes to the function
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue