Spaces:
Runtime error
Runtime error
Update prompts to generate image keywords in the JSON output
Browse files
global_config.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
import logging
|
2 |
import os
|
3 |
|
@@ -10,10 +13,14 @@ load_dotenv()
|
|
10 |
|
11 |
@dataclass(frozen=True)
|
12 |
class GlobalConfig:
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
LLM_MODEL_TEMPERATURE: float = 0.2
|
15 |
-
LLM_MODEL_MIN_OUTPUT_LENGTH: int =
|
16 |
-
LLM_MODEL_MAX_OUTPUT_LENGTH: int = 4096
|
17 |
LLM_MODEL_MAX_INPUT_LENGTH: int = 750
|
18 |
|
19 |
HUGGINGFACEHUB_API_TOKEN = os.environ.get('HUGGINGFACEHUB_API_TOKEN', '')
|
@@ -25,8 +32,8 @@ class GlobalConfig:
|
|
25 |
PRELOAD_DATA_FILE = 'examples/example_02.json'
|
26 |
SLIDES_TEMPLATE_FILE = 'langchain_templates/template_combined.txt'
|
27 |
# JSON_TEMPLATE_FILE = 'langchain_templates/text_to_json_template_02.txt'
|
28 |
-
INITIAL_PROMPT_TEMPLATE = 'langchain_templates/chat_prompts/
|
29 |
-
REFINEMENT_PROMPT_TEMPLATE = 'langchain_templates/chat_prompts/
|
30 |
|
31 |
PPTX_TEMPLATE_FILES = {
|
32 |
'Basic': {
|
|
|
1 |
+
"""
|
2 |
+
A set of configurations used by the app.
|
3 |
+
"""
|
4 |
import logging
|
5 |
import os
|
6 |
|
|
|
13 |
|
14 |
@dataclass(frozen=True)
|
15 |
class GlobalConfig:
|
16 |
+
"""
|
17 |
+
A data class holding the configurations.
|
18 |
+
"""
|
19 |
+
|
20 |
+
HF_LLM_MODEL_NAME = 'mistralai/Mistral-Nemo-Instruct-2407'
|
21 |
LLM_MODEL_TEMPERATURE: float = 0.2
|
22 |
+
LLM_MODEL_MIN_OUTPUT_LENGTH: int = 100
|
23 |
+
LLM_MODEL_MAX_OUTPUT_LENGTH: int = 4 * 4096
|
24 |
LLM_MODEL_MAX_INPUT_LENGTH: int = 750
|
25 |
|
26 |
HUGGINGFACEHUB_API_TOKEN = os.environ.get('HUGGINGFACEHUB_API_TOKEN', '')
|
|
|
32 |
PRELOAD_DATA_FILE = 'examples/example_02.json'
|
33 |
SLIDES_TEMPLATE_FILE = 'langchain_templates/template_combined.txt'
|
34 |
# JSON_TEMPLATE_FILE = 'langchain_templates/text_to_json_template_02.txt'
|
35 |
+
INITIAL_PROMPT_TEMPLATE = 'langchain_templates/chat_prompts/initial_template_v4_two_cols_img.txt'
|
36 |
+
REFINEMENT_PROMPT_TEMPLATE = 'langchain_templates/chat_prompts/refinement_template_v4_two_cols_img.txt'
|
37 |
|
38 |
PPTX_TEMPLATE_FILES = {
|
39 |
'Basic': {
|
langchain_templates/chat_prompts/initial_template_v4_two_cols_img.txt
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. You are experienced with PowerPoint.
|
2 |
+
|
3 |
+
Create the slides for a presentation on the given topic.
|
4 |
+
Include main headings for each slide, detailed bullet points for each slide.
|
5 |
+
Add relevant content to each slide.
|
6 |
+
The content of each slide should be VERBOSE, DESCRIPTIVE, and very DETAILED.
|
7 |
+
If relevant, add one or two EXAMPLES to illustrate the concept.
|
8 |
+
For two or three important slides, generate the key message that those slides convey.
|
9 |
+
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>. Limit this to max two or three slides.
|
10 |
+
Also, add at least one slide with a double column layout by generating appropriate content based on the description in the JSON schema provided below.
|
11 |
+
In addition, for each slide, add image keywords based on the content of the respective slides.
|
12 |
+
These keywords will be later used to search for images from the Web relevant to the slide content.
|
13 |
+
ALWAYS add a concluding slide at the end, containing a list of the key takeaways and an optional call-to-action if relevant to the context.
|
14 |
+
Unless explicitly instructed, create 10 TO 12 SLIDES in total.
|
15 |
+
|
16 |
+
|
17 |
+
### Topic:
|
18 |
+
{question}
|
19 |
+
|
20 |
+
|
21 |
+
The output must be only a valid and syntactically correct JSON adhering to the following schema:
|
22 |
+
{{
|
23 |
+
"title": "Presentation Title",
|
24 |
+
"slides": [
|
25 |
+
{{
|
26 |
+
"heading": "Heading for the First Slide",
|
27 |
+
"bullet_points": [
|
28 |
+
"First bullet point",
|
29 |
+
[
|
30 |
+
"Sub-bullet point 1",
|
31 |
+
"Sub-bullet point 2"
|
32 |
+
],
|
33 |
+
"Second bullet point"
|
34 |
+
],
|
35 |
+
"key_message": "",
|
36 |
+
"img_keywords": "a few keywords"
|
37 |
+
}},
|
38 |
+
{{
|
39 |
+
"heading": "Heading for the Second Slide",
|
40 |
+
"bullet_points": [
|
41 |
+
"First bullet point",
|
42 |
+
"Second bullet item",
|
43 |
+
"Third bullet point"
|
44 |
+
],
|
45 |
+
"key_message": "The key message conveyed in this slide",
|
46 |
+
"img_keywords": "some keywords for this slide"
|
47 |
+
}},
|
48 |
+
{{
|
49 |
+
"heading": "A slide that describes a step-by-step/sequential process",
|
50 |
+
"bullet_points": [
|
51 |
+
">> The first step of the process (begins with special marker >>)",
|
52 |
+
">> A second step (begins with >>)",
|
53 |
+
">> Third step",
|
54 |
+
],
|
55 |
+
"key_message": "",
|
56 |
+
"img_keywords": ""
|
57 |
+
}},
|
58 |
+
{{
|
59 |
+
"heading": "A slide with a double column layout (useful for side-by-side comparison/contrasting of two related concepts, e.g., pros & cons, advantages & risks, old approach vs. modern approach, and so on)",
|
60 |
+
"bullet_points": [
|
61 |
+
{{
|
62 |
+
"heading": "Heading of the left column",
|
63 |
+
"bullet_points": [
|
64 |
+
"First bullet point",
|
65 |
+
"Second bullet item",
|
66 |
+
"Third bullet point"
|
67 |
+
]
|
68 |
+
}},
|
69 |
+
{{
|
70 |
+
"heading": "Heading of the right column",
|
71 |
+
"bullet_points": [
|
72 |
+
"First bullet point",
|
73 |
+
"Second bullet item",
|
74 |
+
"Third bullet point"
|
75 |
+
]
|
76 |
+
}}
|
77 |
+
],
|
78 |
+
"key_message": "",
|
79 |
+
"img_keywords": ""
|
80 |
+
}}
|
81 |
+
]
|
82 |
+
}}
|
83 |
+
|
84 |
+
|
85 |
+
### Output:
|
86 |
+
```json
|
langchain_templates/chat_prompts/refinement_template_v4_two_cols_img.txt
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. You are experienced with PowerPoint.
|
2 |
+
|
3 |
+
A list of user instructions is provided below in sequential order -- from the oldest to the latest.
|
4 |
+
The previously generated content of the slide deck in JSON format is also provided.
|
5 |
+
Follow the instructions to revise the content of the previously generated slides of the presentation on the given topic.
|
6 |
+
Include main headings for each slide, detailed bullet points for each slide.
|
7 |
+
Add relevant content to each slide.
|
8 |
+
The content of each slide should be VERBOSE, DESCRIPTIVE, and very DETAILED.
|
9 |
+
If relevant, add one or two EXAMPLES to illustrate the concept.
|
10 |
+
For two or three important slides, generate the key message that those slides convey.
|
11 |
+
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>. Limit this to max two or three slides.
|
12 |
+
Also, add at least one slide with a double column layout by generating appropriate content based on the description in the JSON schema provided below.
|
13 |
+
In addition, for each slide, add image keywords based on the content of the respective slides.
|
14 |
+
These keywords will be later used to search for images from the Web relevant to the slide content.
|
15 |
+
ALWAYS add a concluding slide at the end, containing a list of the key takeaways and an optional call-to-action if relevant to the context.
|
16 |
+
Unless explicitly instructed, create 10 TO 12 SLIDES in total.
|
17 |
+
|
18 |
+
|
19 |
+
### List of instructions:
|
20 |
+
{instructions}
|
21 |
+
|
22 |
+
|
23 |
+
### Previously generated slide deck content as JSON:
|
24 |
+
{previous_content}
|
25 |
+
|
26 |
+
|
27 |
+
The output must be only a valid and syntactically correct JSON adhering to the following schema:
|
28 |
+
{{
|
29 |
+
"title": "Presentation Title",
|
30 |
+
"slides": [
|
31 |
+
{{
|
32 |
+
"heading": "Heading for the First Slide",
|
33 |
+
"bullet_points": [
|
34 |
+
"First bullet point",
|
35 |
+
[
|
36 |
+
"Sub-bullet point 1",
|
37 |
+
"Sub-bullet point 2"
|
38 |
+
],
|
39 |
+
"Second bullet point"
|
40 |
+
],
|
41 |
+
"key_message": "",
|
42 |
+
"img_keywords": "a few keywords"
|
43 |
+
}},
|
44 |
+
{{
|
45 |
+
"heading": "Heading for the Second Slide",
|
46 |
+
"bullet_points": [
|
47 |
+
"First bullet point",
|
48 |
+
"Second bullet item",
|
49 |
+
"Third bullet point"
|
50 |
+
],
|
51 |
+
"key_message": "The key message conveyed in this slide",
|
52 |
+
"img_keywords": "some keywords for this slide"
|
53 |
+
}},
|
54 |
+
{{
|
55 |
+
"heading": "A slide that describes a step-by-step/sequential process",
|
56 |
+
"bullet_points": [
|
57 |
+
">> The first step of the process (begins with special marker >>)",
|
58 |
+
">> A second step (begins with >>)",
|
59 |
+
">> Third step",
|
60 |
+
],
|
61 |
+
"key_message": "",
|
62 |
+
"img_keywords": ""
|
63 |
+
}},
|
64 |
+
{{
|
65 |
+
"heading": "A slide with a double column layout (useful for side-by-side comparison/contrasting of two related concepts, e.g., pros & cons, advantages & risks, old approach vs. modern approach, and so on)",
|
66 |
+
"bullet_points": [
|
67 |
+
{{
|
68 |
+
"heading": "Heading of the left column",
|
69 |
+
"bullet_points": [
|
70 |
+
"First bullet point",
|
71 |
+
"Second bullet item",
|
72 |
+
"Third bullet point"
|
73 |
+
]
|
74 |
+
}},
|
75 |
+
{{
|
76 |
+
"heading": "Heading of the right column",
|
77 |
+
"bullet_points": [
|
78 |
+
"First bullet point",
|
79 |
+
"Second bullet item",
|
80 |
+
"Third bullet point"
|
81 |
+
]
|
82 |
+
}}
|
83 |
+
],
|
84 |
+
"key_message": "",
|
85 |
+
"img_keywords": ""
|
86 |
+
}}
|
87 |
+
]
|
88 |
+
}}
|
89 |
+
|
90 |
+
|
91 |
+
### Output:
|
92 |
+
```json
|