jeffrey commited on
Commit
7420a95
1 Parent(s): 14d5ed1

Raise an error when there is no model input at qa creation

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -99,6 +99,10 @@ def run_qa(use_existed_corpus: bool, corpus_df: pd.DataFrame, corpus_file: str,
99
  if os.getenv("OPENAI_API_KEY") is None:
100
  gr.Error("Please submit your OpenAI API key first.")
101
  return "Please submit your OpenAI API key first.", original_qa_df
 
 
 
 
102
  llm = OpenAI(model=model_name)
103
 
104
  if qa_method == "default":
@@ -231,6 +235,6 @@ with gr.Blocks(theme="earneleh/paris") as demo:
231
  upstage_key_textbox.submit(on_submit_upstage_key, inputs=[upstage_key_textbox], outputs=upstage_key_status_box)
232
 
233
 
234
- # if __name__ == "__main__":
235
- # demo.launch(share=False, debug=True)
236
- demo.launch(share=False, debug=False)
 
99
  if os.getenv("OPENAI_API_KEY") is None:
100
  gr.Error("Please submit your OpenAI API key first.")
101
  return "Please submit your OpenAI API key first.", original_qa_df
102
+ if model_name is None:
103
+ gr.Error("Please select a model first.")
104
+ return "Please select a model first.", original_qa_df
105
+
106
  llm = OpenAI(model=model_name)
107
 
108
  if qa_method == "default":
 
235
  upstage_key_textbox.submit(on_submit_upstage_key, inputs=[upstage_key_textbox], outputs=upstage_key_status_box)
236
 
237
 
238
+ if __name__ == "__main__":
239
+ demo.launch(share=False, debug=True)
240
+ # demo.launch(share=False, debug=False)