Spaces:
Sleeping
Sleeping
v55
Browse files
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 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
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 |
|