ysharma HF staff commited on
Commit
ebd5d39
·
1 Parent(s): 775c97a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -17
app.py CHANGED
@@ -69,15 +69,12 @@ def predict_beta(message, chatbot=[], temperature=0.9, max_new_tokens=256, top_p
69
  raise gr.Error(json_obj['error'] + ' Please refresh and try again with smaller input prompt')
70
  else:
71
  warning_msg = f"Unexpected response: {json_obj}"
72
- print(warning_msg)
73
- raise ValueError(warning_msg)
74
- except requests.HTTPError:
75
- error_msg = f"Request failed with status code {response.status_code}"
76
- print(error_msg)
77
  raise gr.Error(error_msg)
78
- except json.JSONDecodeError:
79
- error_msg = f"Failed to decode response as JSON: {response.text}"
80
- print(error_msg)
81
  raise gr.Error(error_msg)
82
 
83
 
@@ -110,15 +107,12 @@ def predict_alpha(message, chatbot=[], temperature=0.9, max_new_tokens=256, top_
110
  raise gr.Error(json_obj['error'] + ' Please refresh and try again with smaller input prompt')
111
  else:
112
  warning_msg = f"Unexpected response: {json_obj}"
113
- print(warning_msg)
114
- raise ValueError(warning_msg)
115
- except requests.HTTPError:
116
- error_msg = f"Request failed with status code {response.status_code}"
117
- print(error_msg)
118
  raise gr.Error(error_msg)
119
- except json.JSONDecodeError:
120
- error_msg = f"Failed to decode response as JSON: {response.text}"
121
- print(error_msg)
122
  raise gr.Error(error_msg)
123
 
124
 
@@ -162,6 +156,17 @@ Welcome to the Zephyr Playground! This interactive space lets you experience the
162
  Note: All rights, including licensing and acceptable use policies, related to the Zephyr models, can be found on their respective model pages on Hugging Face.
163
  """
164
 
 
 
 
 
 
 
 
 
 
 
 
165
  # Create chatbot components
166
  chat_beta = gr.Chatbot(label="zephyr-7b-beta")
167
  chat_alpha = gr.Chatbot(label="zephyr-7b-alpha")
@@ -174,7 +179,7 @@ retry = gr.Button('🔄Retry', variant='secondary')
174
  undo = gr.Button('↩️Undo', variant='secondary')
175
 
176
  # Layout the components using Gradio Blocks API
177
- with gr.Blocks() as demo:
178
  gr.HTML(f'<h1><center> {title} </center></h1>')
179
  gr.Markdown(description)
180
  with gr.Row():
 
69
  raise gr.Error(json_obj['error'] + ' Please refresh and try again with smaller input prompt')
70
  else:
71
  warning_msg = f"Unexpected response: {json_obj}"
72
+ raise gr.Error(warning_msg)
73
+ except requests.HTTPError as e:
74
+ error_msg = f"Request failed with status code {e.response.status_code}"
 
 
75
  raise gr.Error(error_msg)
76
+ except json.JSONDecodeError as e:
77
+ error_msg = f"Failed to decode response as JSON: {str(e)}"
 
78
  raise gr.Error(error_msg)
79
 
80
 
 
107
  raise gr.Error(json_obj['error'] + ' Please refresh and try again with smaller input prompt')
108
  else:
109
  warning_msg = f"Unexpected response: {json_obj}"
110
+ raise gr.Error(warning_msg)
111
+ except requests.HTTPError as e:
112
+ error_msg = f"Request failed with status code {e.response.status_code}"
 
 
113
  raise gr.Error(error_msg)
114
+ except json.JSONDecodeError as e:
115
+ error_msg = f"Failed to decode response as JSON: {str(e)}"
 
116
  raise gr.Error(error_msg)
117
 
118
 
 
156
  Note: All rights, including licensing and acceptable use policies, related to the Zephyr models, can be found on their respective model pages on Hugging Face.
157
  """
158
 
159
+
160
+ css = """
161
+ .gradio-container {
162
+ width: 100vw !important;
163
+ min-height: 100vh !important;
164
+ padding:0 !important;
165
+ margin:0 !important;
166
+ max-width: none !important;
167
+ }
168
+ """
169
+
170
  # Create chatbot components
171
  chat_beta = gr.Chatbot(label="zephyr-7b-beta")
172
  chat_alpha = gr.Chatbot(label="zephyr-7b-alpha")
 
179
  undo = gr.Button('↩️Undo', variant='secondary')
180
 
181
  # Layout the components using Gradio Blocks API
182
+ with gr.Blocks(css=css) as demo:
183
  gr.HTML(f'<h1><center> {title} </center></h1>')
184
  gr.Markdown(description)
185
  with gr.Row():