AlekseyKorshuk commited on
Commit
67cbf92
1 Parent(s): bdb77cf
Files changed (1) hide show
  1. models/base.py +9 -2
models/base.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  import requests
3
-
4
  from conversation import Conversation
5
 
6
 
@@ -38,5 +38,12 @@ class BaseModel:
38
  parameters.update(custom_generation_params)
39
  payload = {'instances': [text], "parameters": parameters}
40
  resp = requests.post(api, json=payload, timeout=600)
41
- assert resp.status_code == 200, (resp.content, resp.status_code)
 
 
 
 
 
 
 
42
  return resp.json()["predictions"][0].strip()
 
1
  import os
2
  import requests
3
+ import gradio as gr
4
  from conversation import Conversation
5
 
6
 
 
38
  parameters.update(custom_generation_params)
39
  payload = {'instances': [text], "parameters": parameters}
40
  resp = requests.post(api, json=payload, timeout=600)
41
+ if resp.status_code != 200:
42
+ gr.Error(f"Endpoint returned code: {resp.status_code}.\n"
43
+ f"Content: {resp.content}.\n"
44
+ f"Notes:\n"
45
+ f"- we have scale-to-zero enabled, so please wait for some minutes and try again.\n"
46
+ f"- probably the response generated by the model is to big, try changing max_new_tokens.\n"
47
+ f"- if nothing helps — report the problem.")
48
+ # assert resp.status_code == 200, (resp.content, resp.status_code)
49
  return resp.json()["predictions"][0].strip()