guipenedo HF staff commited on
Commit
07466ed
1 Parent(s): f441bd4

Catch and show generation errors

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -58,7 +58,10 @@ def generate(
58
  seed = seed + 1
59
  formatted_prompt = format_prompt(prompt, history, system_prompt)
60
 
61
- stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
 
 
 
62
  output = ""
63
 
64
  for response in stream:
 
58
  seed = seed + 1
59
  formatted_prompt = format_prompt(prompt, history, system_prompt)
60
 
61
+ try:
62
+ stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
63
+ except Exception as e:
64
+ raise gr.Error(f"Error while generating: {e}")
65
  output = ""
66
 
67
  for response in stream: