fix: resolve KeyError: 'question' in chat_dashboard prompt template (#2695)

Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
This commit is contained in:
Eric Wong 2025-05-15 16:41:38 +08:00 committed by GitHub
parent d300a4d412
commit d2429eeff4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,6 +95,19 @@ class ChatDashboard(BaseChat):
"supported_chat_type": self.dashboard_template["supported_chart_type"],
}
# Mapping variable names: compatible with custom prompt template variable names
# Get the input_variables of the current prompt
input_variables = []
if hasattr(self.prompt_template, "prompt") and hasattr(
self.prompt_template.prompt, "input_variables"
):
input_variables = self.prompt_template.prompt.input_variables
# Compatible with question and user_input
if "question" in input_variables:
input_values["question"] = self.current_user_input
if "user_input" in input_variables:
input_values["user_input"] = self.current_user_input
return input_values
def do_action(self, prompt_response):