Vishwas1 commited on
Commit
b945f79
·
1 Parent(s): 0d65f34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -14,19 +14,20 @@ def text_generate(prompt):
14
  "context":prompt,
15
  "top_p": 0.9,
16
  "temp": 0.75}
17
-
18
- response = requests.post(url, json=data)
19
- if response.status_code == 200:
20
  data_str=response.json()
21
  slack_msg="Supplied Prompt was :"+data["context"]+"\n\n"
22
  slack_msg = slack_msg+"Response receievd was : \n\n"
23
  for i in range(4):
24
  slack_msg = slack_msg+data_str["completions"][i]["completion"]+"\n\n"
25
  slack_msg = slack_msg+data_str["completions"][i]["log_prob"]+"\n\n"
26
- else:
27
  slack_msg="Failed to send JSON message to URL"+response.status_code
28
- return slack_msg
29
-
 
30
  @app.route("/")
31
  def index():
32
  return 'Hello'
 
14
  "context":prompt,
15
  "top_p": 0.9,
16
  "temp": 0.75}
17
+ try:
18
+ response = requests.post(url, json=data)
19
+ if response.status_code == 200:
20
  data_str=response.json()
21
  slack_msg="Supplied Prompt was :"+data["context"]+"\n\n"
22
  slack_msg = slack_msg+"Response receievd was : \n\n"
23
  for i in range(4):
24
  slack_msg = slack_msg+data_str["completions"][i]["completion"]+"\n\n"
25
  slack_msg = slack_msg+data_str["completions"][i]["log_prob"]+"\n\n"
26
+ else:
27
  slack_msg="Failed to send JSON message to URL"+response.status_code
28
+ except:
29
+ slack_msg="Failed to send JSON message to URL"+response.status_code
30
+ return slack_msg
31
  @app.route("/")
32
  def index():
33
  return 'Hello'