aichina commited on
Commit
17b56f6
1 Parent(s): af53e78
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -31,6 +31,10 @@ def create(prompt,openai_key):
31
  print(r.text)
32
  return r.json()
33
 
 
 
 
 
34
 
35
  def convert(res,openai_key):
36
 
@@ -44,10 +48,12 @@ def convert(res,openai_key):
44
  answer = ''
45
 
46
  try:
47
-
48
- prompt = f"将下面的内容,总结10条要点出来,\n{auido_txt}"
49
- open_ai_res = create(prompt,openai_key)
50
- answer = open_ai_res['choices'][0]['text']
 
 
51
  except Exception as e:
52
  print('open ai api error',e)
53
 
 
31
  print(r.text)
32
  return r.json()
33
 
34
+ def split_list(l, n):
35
+ for i in range(0, len(l), n):
36
+ yield l[i:i+n]
37
+
38
 
39
  def convert(res,openai_key):
40
 
 
48
  answer = ''
49
 
50
  try:
51
+ answer = ''
52
+ for txt_line in split_list(content,20):
53
+ txt_line_content = '\n'.join(txt_line)
54
+ prompt = f"将下面的内容,总结10条要点出来,\n{txt_line_content}"
55
+ open_ai_res = create(prompt,openai_key)
56
+ answer += open_ai_res['choices'][0]['text']
57
  except Exception as e:
58
  print('open ai api error',e)
59