Spaces:
Sleeping
Sleeping
Commit
·
347bbc4
1
Parent(s):
103f38e
20230619
Browse files- digester/chatgpt_service.py +5 -0
- digester/gradio_method_service.py +15 -8
- digester/gradio_ui_service.py +1 -1
- digester/util.py +1 -0
- requirements.txt +1 -1
digester/chatgpt_service.py
CHANGED
|
@@ -96,6 +96,11 @@ class ChatGPTService:
|
|
| 96 |
chatbot[-1] = (user_say, chatbot_say)
|
| 97 |
yield chatbot, history, status, source_md
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
@staticmethod
|
| 100 |
def get_reduce_token_percent(text):
|
| 101 |
try:
|
|
|
|
| 96 |
chatbot[-1] = (user_say, chatbot_say)
|
| 97 |
yield chatbot, history, status, source_md
|
| 98 |
|
| 99 |
+
@staticmethod
|
| 100 |
+
def say_using_ginputs(user_say, chatbot_say, status, g_inputs: GradioInputs, is_append=True):
|
| 101 |
+
yield from ChatGPTService.say(user_say, chatbot_say,
|
| 102 |
+
g_inputs.chatbot, g_inputs.history, status, g_inputs.source_md, is_append)
|
| 103 |
+
|
| 104 |
@staticmethod
|
| 105 |
def get_reduce_token_percent(text):
|
| 106 |
try:
|
digester/gradio_method_service.py
CHANGED
|
@@ -257,11 +257,6 @@ Example format:
|
|
| 257 |
|
| 258 |
FINAL_SUMMARY_PROMPT = Prompt(
|
| 259 |
prompt_prefix="""
|
| 260 |
-
[VIDEO_TYPE]
|
| 261 |
-
This is the video type
|
| 262 |
-
N things: The youtube will shows N items that will be described in the video. For example "17 cheap purchases that save me time", "10 AMAZING Ways AutoGPT Is Being Used RIGHT NOW"
|
| 263 |
-
Tutorials: how to do or make something in order to teach a skill or how to use a product or software
|
| 264 |
-
|
| 265 |
[TITLE]
|
| 266 |
{title}
|
| 267 |
|
|
@@ -272,7 +267,7 @@ Tutorials: how to do or make something in order to teach a skill or how to use a
|
|
| 272 |
""",
|
| 273 |
prompt_suffix="""
|
| 274 |
[TASK]
|
| 275 |
-
Summarize the above
|
| 276 |
Use markdown format.
|
| 277 |
Must use language: {language}
|
| 278 |
{task_constraint}
|
|
@@ -288,6 +283,8 @@ Additionally, since it is a N things video, the summary should include the N ite
|
|
| 288 |
""",
|
| 289 |
"Tutorials": """
|
| 290 |
Additionally, since it is a Tutorial video, provide step by step instructions for the tutorial.
|
|
|
|
|
|
|
| 291 |
""",
|
| 292 |
}
|
| 293 |
FINAL_SUMMARY_FORMAT_CONSTRAINTS = {
|
|
@@ -298,7 +295,14 @@ Items mentioned in the video: (content of N things. Put different appropriate em
|
|
| 298 |
Instructions: (step by step instructions, up to five concise bullet points, less than 20 words. Put different appropriate emoji for each bullet point)
|
| 299 |
""",
|
| 300 |
"Others": """
|
| 301 |
-
Highlights:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
""",
|
| 303 |
}
|
| 304 |
|
|
@@ -334,10 +338,13 @@ Highlights: [Emoji] (content of highlights, up to five concise bullet points, le
|
|
| 334 |
)
|
| 335 |
prompt_show_user = "Classify the video type for me"
|
| 336 |
response, len_prompts = yield from ChatGPTService.trigger_callgpt_pipeline(prompt, prompt_show_user, g_inputs)
|
|
|
|
| 337 |
try:
|
| 338 |
video_type = json.loads(response)['type']
|
|
|
|
|
|
|
| 339 |
except Exception as e:
|
| 340 |
-
|
| 341 |
video_type = 'Others'
|
| 342 |
return video_type
|
| 343 |
|
|
|
|
| 257 |
|
| 258 |
FINAL_SUMMARY_PROMPT = Prompt(
|
| 259 |
prompt_prefix="""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
[TITLE]
|
| 261 |
{title}
|
| 262 |
|
|
|
|
| 267 |
""",
|
| 268 |
prompt_suffix="""
|
| 269 |
[TASK]
|
| 270 |
+
Summarize the above points under 30 words. Step by step showing points for the main concepts.
|
| 271 |
Use markdown format.
|
| 272 |
Must use language: {language}
|
| 273 |
{task_constraint}
|
|
|
|
| 283 |
""",
|
| 284 |
"Tutorials": """
|
| 285 |
Additionally, since it is a Tutorial video, provide step by step instructions for the tutorial.
|
| 286 |
+
""",
|
| 287 |
+
"Others": """
|
| 288 |
""",
|
| 289 |
}
|
| 290 |
FINAL_SUMMARY_FORMAT_CONSTRAINTS = {
|
|
|
|
| 295 |
Instructions: (step by step instructions, up to five concise bullet points, less than 20 words. Put different appropriate emoji for each bullet point)
|
| 296 |
""",
|
| 297 |
"Others": """
|
| 298 |
+
Highlights:
|
| 299 |
+
- [Emoji] (content of highlights)
|
| 300 |
+
- [Emoji] (content of highlights)
|
| 301 |
+
- [Emoji] (content of highlights)
|
| 302 |
+
- [Emoji] (content of highlights)
|
| 303 |
+
- [Emoji] (content of highlights)
|
| 304 |
+
|
| 305 |
+
For highlight, up to five concise bullet points, less than 15 words for each bullet point. Put different appropriate emoji for each bullet point
|
| 306 |
""",
|
| 307 |
}
|
| 308 |
|
|
|
|
| 338 |
)
|
| 339 |
prompt_show_user = "Classify the video type for me"
|
| 340 |
response, len_prompts = yield from ChatGPTService.trigger_callgpt_pipeline(prompt, prompt_show_user, g_inputs)
|
| 341 |
+
yield from ChatGPTService.say_using_ginputs(None, f"{provide_text_with_css('WARN', 'yellow')} test", "Success", g_inputs)
|
| 342 |
try:
|
| 343 |
video_type = json.loads(response)['type']
|
| 344 |
+
if video_type not in cls.FINAL_SUMMARY_TASK_CONSTRAINTS.keys():
|
| 345 |
+
raise Exception(f"Video type is not valid: {video_type}. Use default: Others")
|
| 346 |
except Exception as e:
|
| 347 |
+
yield from ChatGPTService.say_using_ginputs(None, f"{provide_text_with_css('WARN', 'yellow')} {e}", "Success", g_inputs)
|
| 348 |
video_type = 'Others'
|
| 349 |
return video_type
|
| 350 |
|
digester/gradio_ui_service.py
CHANGED
|
@@ -8,7 +8,7 @@ title_html = """
|
|
| 8 |
<p align=\"center\">
|
| 9 |
DigestEverythingGPT leverages ChatGPT/LLMs to help users quickly understand essential information from various forms of content, such as podcasts, YouTube videos, and PDF documents.<br>
|
| 10 |
The prompt engineering is chained and tuned so that is result is of high quality and fast. It is not a simple single query and response tool.<br>
|
| 11 |
-
Version
|
| 12 |
<a href="https://github.com/michaelthwan/digest-everything-gpt"><i class="fa fa-github"></i> Github</a>
|
| 13 |
) (
|
| 14 |
<a href="https://huggingface.co/spaces/michaelthwan/digest-everything-gpt"> HFSpace</a>
|
|
|
|
| 8 |
<p align=\"center\">
|
| 9 |
DigestEverythingGPT leverages ChatGPT/LLMs to help users quickly understand essential information from various forms of content, such as podcasts, YouTube videos, and PDF documents.<br>
|
| 10 |
The prompt engineering is chained and tuned so that is result is of high quality and fast. It is not a simple single query and response tool.<br>
|
| 11 |
+
Version 20230619 (
|
| 12 |
<a href="https://github.com/michaelthwan/digest-everything-gpt"><i class="fa fa-github"></i> Github</a>
|
| 13 |
) (
|
| 14 |
<a href="https://huggingface.co/spaces/michaelthwan/digest-everything-gpt"> HFSpace</a>
|
digester/util.py
CHANGED
|
@@ -22,6 +22,7 @@ class GradioInputs:
|
|
| 22 |
self.language_textbox = language_textbox
|
| 23 |
self.chatbot = chatbot
|
| 24 |
self.history = history
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
class Prompt:
|
|
|
|
| 22 |
self.language_textbox = language_textbox
|
| 23 |
self.chatbot = chatbot
|
| 24 |
self.history = history
|
| 25 |
+
self.source_md = f"[{self.source_textbox}] {self.source_target_textbox}"
|
| 26 |
|
| 27 |
|
| 28 |
class Prompt:
|
requirements.txt
CHANGED
|
@@ -4,4 +4,4 @@ tiktoken>=0.3.3
|
|
| 4 |
openai
|
| 5 |
Markdown
|
| 6 |
latex2mathml
|
| 7 |
-
everything2text4prompt
|
|
|
|
| 4 |
openai
|
| 5 |
Markdown
|
| 6 |
latex2mathml
|
| 7 |
+
everything2text4prompt
|