Skip to content

Commit a458d15

Browse files
authored
Update route handler to handle empty questions
An exception was thrown when the user submitted an empty question.
1 parent dde2d87 commit a458d15

File tree

1 file changed

+7
-4
lines changed
  • examples/gemini/python/docs-agent/docs_agent/interfaces/chatbot

1 file changed

+7
-4
lines changed

examples/gemini/python/docs-agent/docs_agent/interfaces/chatbot/chatui.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,14 @@ def feedback():
245245
# using input text box.
246246
@bp.route("/result", methods=["GET", "POST"])
247247
def result():
248-
if request.method == "POST":
249-
question = request.form["question"]
250-
return ask_model(question, agent=docs_agent, template=app_template)
251-
else:
248+
if request.method != "POST":
249+
return redirect(url_for(redirect_index))
250+
251+
question = request.form.get("question", "").strip()
252+
if not question:
252253
return redirect(url_for(redirect_index))
254+
255+
return ask_model(question, agent=docs_agent, template=app_template)
253256

254257
# Render a response page when the user clicks a question
255258
# from the related questions list.

0 commit comments

Comments
 (0)