Spaces:
Running
Running
Update prompts & additional info handling on refinement
Browse files
app.py
CHANGED
@@ -142,6 +142,7 @@ APP_TEXT = _load_strings()
|
|
142 |
CHAT_MESSAGES = 'chat_messages'
|
143 |
DOWNLOAD_FILE_KEY = 'download_file_name'
|
144 |
IS_IT_REFINEMENT = 'is_it_refinement'
|
|
|
145 |
|
146 |
|
147 |
logger = logging.getLogger(__name__)
|
@@ -271,12 +272,10 @@ def set_up_chat_ui():
|
|
271 |
accept_file=True,
|
272 |
file_type=['pdf', ],
|
273 |
):
|
274 |
-
print(f'{prompt=}')
|
275 |
prompt_text = prompt.text or ''
|
276 |
if prompt['files']:
|
277 |
-
|
278 |
-
|
279 |
-
additional_text = ''
|
280 |
|
281 |
provider, llm_name = llm_helper.get_provider_model(
|
282 |
llm_provider_to_use,
|
@@ -310,14 +309,14 @@ def set_up_chat_ui():
|
|
310 |
**{
|
311 |
'instructions': '\n'.join(list_of_msgs),
|
312 |
'previous_content': _get_last_response(),
|
313 |
-
'additional_info':
|
314 |
}
|
315 |
)
|
316 |
else:
|
317 |
formatted_template = prompt_template.format(
|
318 |
**{
|
319 |
'question': prompt_text,
|
320 |
-
'additional_info':
|
321 |
}
|
322 |
)
|
323 |
|
|
|
142 |
CHAT_MESSAGES = 'chat_messages'
|
143 |
DOWNLOAD_FILE_KEY = 'download_file_name'
|
144 |
IS_IT_REFINEMENT = 'is_it_refinement'
|
145 |
+
ADDITIONAL_INFO = 'additional_info'
|
146 |
|
147 |
|
148 |
logger = logging.getLogger(__name__)
|
|
|
272 |
accept_file=True,
|
273 |
file_type=['pdf', ],
|
274 |
):
|
|
|
275 |
prompt_text = prompt.text or ''
|
276 |
if prompt['files']:
|
277 |
+
st.session_state[ADDITIONAL_INFO] = get_pdf_contents(prompt['files'][0])
|
278 |
+
print(f'{prompt["files"]=}')
|
|
|
279 |
|
280 |
provider, llm_name = llm_helper.get_provider_model(
|
281 |
llm_provider_to_use,
|
|
|
309 |
**{
|
310 |
'instructions': '\n'.join(list_of_msgs),
|
311 |
'previous_content': _get_last_response(),
|
312 |
+
'additional_info': st.session_state.get(ADDITIONAL_INFO, ''),
|
313 |
}
|
314 |
)
|
315 |
else:
|
316 |
formatted_template = prompt_template.format(
|
317 |
**{
|
318 |
'question': prompt_text,
|
319 |
+
'additional_info': st.session_state.get(ADDITIONAL_INFO, ''),
|
320 |
}
|
321 |
)
|
322 |
|
langchain_templates/chat_prompts/initial_template_v4_two_cols_img.txt
CHANGED
@@ -6,7 +6,10 @@ Add relevant, detailed content to each slide. When relevant, add one or two EXAM
|
|
6 |
For two or three important slides, generate the key message that those slides convey.
|
7 |
|
8 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
9 |
-
|
|
|
|
|
|
|
10 |
If <ADDITIONAL_INFO> is empty, ignore it.
|
11 |
|
12 |
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>.
|
@@ -20,11 +23,12 @@ In addition, create one slide containing 4 TO 6 icons (pictograms) illustrating
|
|
20 |
In this slide, each line of text will begin with the name of a relevant icon enclosed between [[ and ]], e.g., [[machine-learning]] and [[fairness]].
|
21 |
Insert icons only in this slide.
|
22 |
|
23 |
-
Your output, i.e., the content of each slide should be vert detailed and descriptive but not way too verbose
|
|
|
24 |
Each bullet point should be detailed and explanatory, not just short phrases.
|
25 |
|
26 |
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.
|
27 |
-
Unless explicitly instructed with the topic, create 10
|
28 |
|
29 |
|
30 |
### Topic:
|
|
|
6 |
For two or three important slides, generate the key message that those slides convey.
|
7 |
|
8 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
9 |
+
Read this information carefully. Based on the contents provided, plan the structure of the presentation.
|
10 |
+
For example, if it's a paper, you can consider having Problem, Solution, Experiments, and Results, among other sections.
|
11 |
+
If it's a product brochure, you can have Features, Changes, Operating Conditions, and likewise relevant sections.
|
12 |
+
Similarly, decide for other content types. Then appropriately incorporate the contents into the relevant slides, presenting in a useful way.
|
13 |
If <ADDITIONAL_INFO> is empty, ignore it.
|
14 |
|
15 |
Identify if a slide describes a step-by-step/sequential process, then begin the bullet points with a special marker >>.
|
|
|
23 |
In this slide, each line of text will begin with the name of a relevant icon enclosed between [[ and ]], e.g., [[machine-learning]] and [[fairness]].
|
24 |
Insert icons only in this slide.
|
25 |
|
26 |
+
Your output, i.e., the content of each slide should be vert detailed and descriptive but not way too verbose.
|
27 |
+
Avoid writing like a report, but also avoid very short bullet points with just 3-4 words.
|
28 |
Each bullet point should be detailed and explanatory, not just short phrases.
|
29 |
|
30 |
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.
|
31 |
+
Unless explicitly instructed with the topic, create 10 to 12 slides. You must never create more than 15 to 20 slides.
|
32 |
|
33 |
|
34 |
### Topic:
|
langchain_templates/chat_prompts/refinement_template_v4_two_cols_img.txt
CHANGED
@@ -9,7 +9,10 @@ Add relevant, detailed content to each slide. When relevant, add one or two EXAM
|
|
9 |
For two or three important slides, generate the key message that those slides convey.
|
10 |
|
11 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
12 |
-
|
|
|
|
|
|
|
13 |
If <ADDITIONAL_INFO> is empty, ignore it.
|
14 |
|
15 |
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.
|
@@ -22,11 +25,12 @@ In this slide, each line of text will begin with the name of a relevant icon enc
|
|
22 |
Insert icons only in this slide.
|
23 |
Do not repeat any icons or the icons slide.
|
24 |
|
25 |
-
Your output, i.e., the content of each slide should be vert detailed and descriptive but not way too verbose
|
|
|
26 |
Each bullet point should be detailed and explanatory, not just short phrases.
|
27 |
|
28 |
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.
|
29 |
-
Unless explicitly
|
30 |
|
31 |
|
32 |
### List of instructions:
|
|
|
9 |
For two or three important slides, generate the key message that those slides convey.
|
10 |
|
11 |
The <ADDITIONAL_INFO> may provide additional information. If available, you should incorporate them while making the slides.
|
12 |
+
Read this information carefully. Based on the contents provided, plan the structure of the presentation.
|
13 |
+
For example, if it's a paper, you can consider having Problem, Solution, Experiments, and Results, among other sections.
|
14 |
+
If it's a product brochure, you can have Features, Changes, Operating Conditions, and likewise relevant sections.
|
15 |
+
Similarly, decide for other content types. Then appropriately incorporate the contents into the relevant slides, presenting in a useful way.
|
16 |
If <ADDITIONAL_INFO> is empty, ignore it.
|
17 |
|
18 |
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.
|
|
|
25 |
Insert icons only in this slide.
|
26 |
Do not repeat any icons or the icons slide.
|
27 |
|
28 |
+
Your output, i.e., the content of each slide should be vert detailed and descriptive but not way too verbose.
|
29 |
+
Avoid writing like a report, but also avoid very short bullet points with just 3-4 words.
|
30 |
Each bullet point should be detailed and explanatory, not just short phrases.
|
31 |
|
32 |
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.
|
33 |
+
Unless explicitly instructed with the topic, create 10 to 12 slides. You must never create more than 15 to 20 slides.
|
34 |
|
35 |
|
36 |
### List of instructions:
|