Spaces:
Running
Running
Commit
·
6e23a32
1
Parent(s):
50069c7
Strip whitespace from NLP summary and mindmap outputs
Browse files- nlp_summarizer.py +4 -4
nlp_summarizer.py
CHANGED
@@ -19,7 +19,7 @@ def generate_nlp_summary(temp_summary):
|
|
19 |
{"role": "user", "content": f'As a text script expert, please help me to write a short text script with the topic \" {temp_summary}\".You have three tasks, which are:\\n 1.to summarize the text I provided into a Summary .Please answer within 150-300 characters.\\n 2.to summarize the text I provided, using up to seven Highlight.\\n 3.to summarize the text I provided, using up to seven Key Insights. Each insight should include a brief in-depth analysis. Key Insight should not include timestamps.\\n Your output should use the following template strictly, provide the results for the three tasks:\\n ## Summary\\n ## Highlights\\n - Highlights\\n ## Key Insights\\n - Key Insights .\\n Importantly your output must use language \"English\"'}
|
20 |
],
|
21 |
)
|
22 |
-
return completion.choices[0].message.content.replace("**", "").replace("\n\n", "\n").replace("\n \n", "\n").replace("##", "\n##")
|
23 |
except Exception as e:
|
24 |
print(str(e))
|
25 |
return False
|
@@ -41,7 +41,7 @@ def generate_nlp_mindmap(temp_summary):
|
|
41 |
{"role": "user", "content": f'As a text script expert, please help me to write a short text script with the topic \"{temp_summary}\".Your output should use the following template:\\n\\n## {{Subtitle01}}\\n- {{Bulletpoint01}}\\n- {{Bulletpoint02}}\\n## {{Subtitle02}}\\n- {{Bulletpoint03}}\\n- {{Bulletpoint04}}\\n\\nSummarize the giving topic to generate a mind map (as many subtitles as possible, with a minimum of three subtitles) structure markdown. Do not include anything in the response, that is not the part of mindmap.\\n Most Importantly your output must use language \"English\" and each point or pointer should include no more than 9 words.'}
|
42 |
],
|
43 |
)
|
44 |
-
return completion.choices[0].message.content.replace("**", "").replace("\n\n", "\n").replace("\n \n", "\n").replace("##", "\n##")
|
45 |
except Exception as e:
|
46 |
print(str(e))
|
47 |
return False
|
@@ -55,7 +55,7 @@ def generate_nlp_summary_and_mindmap(temp_summary):
|
|
55 |
response["summary"] = None
|
56 |
else:
|
57 |
response["summary_status"] = "success"
|
58 |
-
response["summary"] = nlp_summary
|
59 |
def local_generate_nlp_mindmap():
|
60 |
nlp_mindmap = generate_nlp_mindmap(temp_summary)
|
61 |
if not nlp_mindmap:
|
@@ -63,7 +63,7 @@ def generate_nlp_summary_and_mindmap(temp_summary):
|
|
63 |
response["mindmap"] = None
|
64 |
else:
|
65 |
response["mindmap_status"] = "success"
|
66 |
-
response["mindmap"] = nlp_mindmap
|
67 |
threads = []
|
68 |
threads.append(threading.Thread(target=local_generate_nlp_summary))
|
69 |
threads.append(threading.Thread(target=local_generate_nlp_mindmap))
|
|
|
19 |
{"role": "user", "content": f'As a text script expert, please help me to write a short text script with the topic \" {temp_summary}\".You have three tasks, which are:\\n 1.to summarize the text I provided into a Summary .Please answer within 150-300 characters.\\n 2.to summarize the text I provided, using up to seven Highlight.\\n 3.to summarize the text I provided, using up to seven Key Insights. Each insight should include a brief in-depth analysis. Key Insight should not include timestamps.\\n Your output should use the following template strictly, provide the results for the three tasks:\\n ## Summary\\n ## Highlights\\n - Highlights\\n ## Key Insights\\n - Key Insights .\\n Importantly your output must use language \"English\"'}
|
20 |
],
|
21 |
)
|
22 |
+
return completion.choices[0].message.content.replace("**", "").replace("\n\n", "\n").replace("\n \n", "\n").replace("##", "\n##").strip()
|
23 |
except Exception as e:
|
24 |
print(str(e))
|
25 |
return False
|
|
|
41 |
{"role": "user", "content": f'As a text script expert, please help me to write a short text script with the topic \"{temp_summary}\".Your output should use the following template:\\n\\n## {{Subtitle01}}\\n- {{Bulletpoint01}}\\n- {{Bulletpoint02}}\\n## {{Subtitle02}}\\n- {{Bulletpoint03}}\\n- {{Bulletpoint04}}\\n\\nSummarize the giving topic to generate a mind map (as many subtitles as possible, with a minimum of three subtitles) structure markdown. Do not include anything in the response, that is not the part of mindmap.\\n Most Importantly your output must use language \"English\" and each point or pointer should include no more than 9 words.'}
|
42 |
],
|
43 |
)
|
44 |
+
return completion.choices[0].message.content.replace("**", "").replace("\n\n", "\n").replace("\n \n", "\n").replace("##", "\n##").strip()
|
45 |
except Exception as e:
|
46 |
print(str(e))
|
47 |
return False
|
|
|
55 |
response["summary"] = None
|
56 |
else:
|
57 |
response["summary_status"] = "success"
|
58 |
+
response["summary"] = nlp_summary.strip()
|
59 |
def local_generate_nlp_mindmap():
|
60 |
nlp_mindmap = generate_nlp_mindmap(temp_summary)
|
61 |
if not nlp_mindmap:
|
|
|
63 |
response["mindmap"] = None
|
64 |
else:
|
65 |
response["mindmap_status"] = "success"
|
66 |
+
response["mindmap"] = nlp_mindmap.strip()
|
67 |
threads = []
|
68 |
threads.append(threading.Thread(target=local_generate_nlp_summary))
|
69 |
threads.append(threading.Thread(target=local_generate_nlp_mindmap))
|