johann22 commited on
Commit
ea51b34
β€’
1 Parent(s): 37ef71b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -57,16 +57,24 @@ def run(purpose,history,model_drop):
57
  history=str(history).strip("[]")
58
  if not history:
59
  history = ""
60
- out_prompt = run_gpt(purpose,history)
 
 
 
61
  yield ("",[(purpose,out_prompt)],None)
62
- model=loaded_model[int(model_drop)]
63
- out_img=model(out_prompt)
64
- print(out_img)
65
- image=f'{base_url}file={out_img}'
66
- uid = uuid.uuid4()
67
- urllib.request.urlretrieve(image, f'{uid}.png')
68
- return ("",[(purpose,out_prompt)],f'{uid}.png')
 
 
 
 
69
  #return ("", [(purpose,history)])
 
70
 
71
 
72
 
 
57
  history=str(history).strip("[]")
58
  if not history:
59
  history = ""
60
+ try:
61
+ out_prompt = run_gpt(purpose,history)
62
+ except Exception as e:
63
+ out_prompt = f"An Error Occured generating the prompt \n {e}"
64
  yield ("",[(purpose,out_prompt)],None)
65
+ try:
66
+ model=loaded_model[int(model_drop)]
67
+ out_img=model(out_prompt)
68
+ print(out_img)
69
+ image=f'{base_url}file={out_img}'
70
+ uid = uuid.uuid4()
71
+ urllib.request.urlretrieve(image, f'{uid}.png')
72
+ return ("",[(purpose,out_prompt)],f'{uid}.png')
73
+
74
+ except Exception as e:
75
+ print (e)
76
  #return ("", [(purpose,history)])
77
+ return ("An Error Occured generating the image",[(purpose,out_prompt)],None)
78
 
79
 
80