From 0960acb4a2601e6e5100f1cf13a68f831768158d Mon Sep 17 00:00:00 2001 From: Fangyin Cheng Date: Thu, 22 Feb 2024 11:27:21 +0800 Subject: [PATCH] fix: Fix load some dbgpts error --- dbgpt/core/awel/flow/base.py | 12 +++++++++--- dbgpt/core/interface/operators/prompt_operator.py | 6 +++--- dbgpt/util/dbgpts/repo.py | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dbgpt/core/awel/flow/base.py b/dbgpt/core/awel/flow/base.py index 197bfb819..ecd84d3c6 100644 --- a/dbgpt/core/awel/flow/base.py +++ b/dbgpt/core/awel/flow/base.py @@ -642,6 +642,9 @@ def get_runnable_parameters( for parameter in self.parameters if not parameter.optional } + current_parameters = { + parameter.name: parameter for parameter in self.parameters + } if len(view_required_parameters) < len(current_required_parameters): # TODO, skip the optional parameters. raise FlowParameterMetadataException( @@ -651,10 +654,13 @@ def get_runnable_parameters( f"Required parameters: {current_required_parameters.keys()}, " f"but got {view_required_parameters.keys()}." ) - for i, parameter in enumerate(self.parameters): - view_param = view_parameters[i] + for view_param_key, view_param in view_required_parameters.items(): + if view_param_key not in current_parameters: + raise FlowParameterMetadataException( + f"Parameter {view_param_key} not found in the metadata." + ) runnable_parameters.update( - parameter.to_runnable_parameter( + current_parameters[view_param_key].to_runnable_parameter( view_param.get_typed_value(), resources, key_to_resource_instance ) ) diff --git a/dbgpt/core/interface/operators/prompt_operator.py b/dbgpt/core/interface/operators/prompt_operator.py index 0018101e8..4a965b628 100644 --- a/dbgpt/core/interface/operators/prompt_operator.py +++ b/dbgpt/core/interface/operators/prompt_operator.py @@ -74,11 +74,11 @@ class CommonChatPromptTemplate(ChatPromptTemplate): def pre_fill(cls, values: Dict[str, Any]) -> Dict[str, Any]: """Pre fill the messages.""" if "system_message" not in values: - raise ValueError("No system message") + values["system_message"] = "You are a helpful AI Assistant." if "human_message" not in values: - raise ValueError("No human message") + values["human_message"] = "{user_input}" if "message_placeholder" not in values: - raise ValueError("No message placeholder") + values["message_placeholder"] = "chat_history" system_message = values.pop("system_message") human_message = values.pop("human_message") message_placeholder = values.pop("message_placeholder") diff --git a/dbgpt/util/dbgpts/repo.py b/dbgpt/util/dbgpts/repo.py index 7ab471821..e86c836a7 100644 --- a/dbgpt/util/dbgpts/repo.py +++ b/dbgpt/util/dbgpts/repo.py @@ -140,7 +140,7 @@ def update_repo(repo: str): logger.info(f"Repo '{repo}' is not a git repository.") return logger.info(f"Updating repo '{repo}'...") - subprocess.run(["git", "pull"], check=True) + subprocess.run(["git", "pull"], check=False) def install(