qq1023 commited on
Commit
3e4e27e
1 Parent(s): 48cef06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -114,7 +114,10 @@ def query(category, text):
114
  1. Construct a prompt
115
  2. Generate a response
116
  """
117
- category = Category[category]
 
 
 
118
  chain = categories.category_modules[category].chain
119
  formatted_prompt = chain.prompt.format_prompt(
120
  text=text,
 
114
  1. Construct a prompt
115
  2. Generate a response
116
  """
117
+ try:
118
+ category = Category[category]
119
+ except KeyError:
120
+ return [{"error": f"Invalid category: {category}"}]
121
  chain = categories.category_modules[category].chain
122
  formatted_prompt = chain.prompt.format_prompt(
123
  text=text,