JLW commited on
Commit
fa42e0a
1 Parent(s): 43e9bf4

Print message if there isn't an API key pasted

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -43,6 +43,9 @@ def openai_create(prompt, openai_api_key):
43
 
44
 
45
  def calc_gpt_only(math_problem, openai_api_key):
 
 
 
46
  answer = openai_create(gpt_only_prompt + math_problem + "\n", openai_api_key)
47
 
48
  print("\n==== date/time: " + str(datetime.datetime.now()) + " ====")
@@ -54,6 +57,9 @@ def calc_gpt_only(math_problem, openai_api_key):
54
 
55
 
56
  def calc_gpt_pal(math_problem, pal_chain):
 
 
 
57
  answer = pal_chain.run(math_problem)
58
 
59
  print("\n==== date/time: " + str(datetime.datetime.now()) + " ====")
 
43
 
44
 
45
  def calc_gpt_only(math_problem, openai_api_key):
46
+ if not openai_api_key or openai_api_key == "":
47
+ return "<pre>Please paste your OpenAI API key</pre>"
48
+
49
  answer = openai_create(gpt_only_prompt + math_problem + "\n", openai_api_key)
50
 
51
  print("\n==== date/time: " + str(datetime.datetime.now()) + " ====")
 
57
 
58
 
59
  def calc_gpt_pal(math_problem, pal_chain):
60
+ if not pal_chain:
61
+ return "<pre>Please paste your OpenAI API key</pre>"
62
+
63
  answer = pal_chain.run(math_problem)
64
 
65
  print("\n==== date/time: " + str(datetime.datetime.now()) + " ====")