Skip to content

Commit d2429ee

Browse files
WangzJifangyinc
andauthored
fix: resolve KeyError: 'question' in chat_dashboard prompt template (#2695)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
1 parent d300a4d commit d2429ee

File tree

1 file changed

+13
-0
lines changed
  • packages/dbgpt-app/src/dbgpt_app/scene/chat_dashboard

1 file changed

+13
-0
lines changed

packages/dbgpt-app/src/dbgpt_app/scene/chat_dashboard/chat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ async def generate_input_values(self) -> Dict:
9595
"supported_chat_type": self.dashboard_template["supported_chart_type"],
9696
}
9797

98+
# Mapping variable names: compatible with custom prompt template variable names
99+
# Get the input_variables of the current prompt
100+
input_variables = []
101+
if hasattr(self.prompt_template, "prompt") and hasattr(
102+
self.prompt_template.prompt, "input_variables"
103+
):
104+
input_variables = self.prompt_template.prompt.input_variables
105+
# Compatible with question and user_input
106+
if "question" in input_variables:
107+
input_values["question"] = self.current_user_input
108+
if "user_input" in input_variables:
109+
input_values["user_input"] = self.current_user_input
110+
98111
return input_values
99112

100113
def do_action(self, prompt_response):

0 commit comments

Comments
 (0)