bstraehle commited on
Commit
9ba1127
·
verified ·
1 Parent(s): d16721c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -50,26 +50,31 @@ def ask(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name =
50
  tuple: (answer, console_logs) - The answer to the question and captured console output
51
  """
52
  if not question:
53
- gr.Warning("Question is required.")
54
- return "", ""
 
55
 
56
  if not openai_api_key:
57
- gr.Warning("OpenAI API Key is required.")
58
- return "", ""
 
59
 
60
  if not gemini_api_key:
61
- gr.Warning("Gemini API Key is required.")
62
- return "", ""
 
63
 
64
  if not anthropic_api_key:
65
- gr.Warning("Anthropic API Key is required.")
66
- return "", ""
 
67
 
68
  is_valid, err_msg = validate_input(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name)
69
 
70
  if not is_valid:
71
- gr.Warning(f"Invalid input: {err_msg}")
72
- return "", ""
 
73
 
74
  if file_name:
75
  file_name = f"files/{file_name}"
@@ -94,9 +99,9 @@ def ask(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name =
94
 
95
  return answer, console_logs
96
  except Exception as e:
97
- error_msg = str(e)
98
- gr.Warning(error_msg)
99
- return "", f"Error: {error_msg}"
100
 
101
  # Helper functions
102
 
 
50
  tuple: (answer, console_logs) - The answer to the question and captured console output
51
  """
52
  if not question:
53
+ msg = "Question is required."
54
+ gr.Warning(msg)
55
+ return None, msg
56
 
57
  if not openai_api_key:
58
+ msg = "OpenAI API Key is required."
59
+ gr.Warning(msg)
60
+ return None, msg
61
 
62
  if not gemini_api_key:
63
+ msg = "Gemini API Key is required."
64
+ gr.Warning(msg)
65
+ return None, msg
66
 
67
  if not anthropic_api_key:
68
+ msg = "Anthropic API Key is required."
69
+ gr.Warning(msg)
70
+ return None, msg
71
 
72
  is_valid, err_msg = validate_input(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name)
73
 
74
  if not is_valid:
75
+ msg = f"Invalid input: {err_msg}"
76
+ gr.Warning(msg)
77
+ return None, msg
78
 
79
  if file_name:
80
  file_name = f"files/{file_name}"
 
99
 
100
  return answer, console_logs
101
  except Exception as e:
102
+ msg = str(e)
103
+ gr.Warning(msg)
104
+ return None, f"Error: {msg}"
105
 
106
  # Helper functions
107