chappyzhou commited on
Commit
55915cb
·
1 Parent(s): 5b37a73
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -21,19 +21,18 @@ def completion(prompt):
21
  'stop': None,
22
  # 'stop': [[13, 13]],
23
  }, headers={"Authorization": f"Bearer {st.secrets['token']}"})
24
-
25
- st.success(str(resp))
26
- st.success(resp.text)
27
- print(resp, '\n', resp.text)
28
- answers = resp.json()
29
- answers = [c['text'] for c in answers['choices'] if c['text'] is not None]
30
- cols = st.columns(3)
31
- for idx, answer in enumerate(answers):
32
- if idx >= 3:
33
- break
34
- with cols[idx]:
35
- content = (prompt + answer).replace("\n", "\n\n")
36
- st.markdown(f'## 版本{idx}\n\n{content}')
37
  end = time.monotonic()
38
  st.text(f'耗时:{end - start}')
39
 
 
21
  'stop': None,
22
  # 'stop': [[13, 13]],
23
  }, headers={"Authorization": f"Bearer {st.secrets['token']}"})
24
+ if resp.status_code != 200:
25
+ st.error(f'Bad response: {resp}')
26
+ else:
27
+ answers = resp.json()
28
+ answers = [c['text'] for c in answers['choices'] if c['text'] is not None]
29
+ cols = st.columns(3)
30
+ for idx, answer in enumerate(answers):
31
+ if idx >= 3:
32
+ break
33
+ with cols[idx]:
34
+ content = (prompt + answer).replace("\n", "\n\n")
35
+ st.markdown(f'## 版本{idx}\n\n{content}')
 
36
  end = time.monotonic()
37
  st.text(f'耗时:{end - start}')
38