barunsaha commited on
Commit
a42e3cf
1 Parent(s): da03db8

Add missing chat prompt template

Browse files
chat_app.py CHANGED
@@ -39,7 +39,7 @@ def display_page_footer_content():
39
  Display content in the page footer.
40
  """
41
 
42
- st.text(APP_TEXT['tos'] + '\n' + APP_TEXT['tos2'])
43
  # st.markdown(
44
  # '![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fbarunsaha%2Fslide-deck-ai&countColor=%23263759)' # noqa: E501
45
  # )
@@ -67,11 +67,7 @@ def set_up_chat_ui():
67
  history = StreamlitChatMessageHistory(key='chat_messages')
68
  llm = llm_helper.get_hf_endpoint()
69
 
70
- with open(
71
- 'langchain_templates/template_combined_chat_history.txt',
72
- 'r',
73
- encoding='utf-8'
74
- ) as in_file:
75
  template = in_file.read()
76
 
77
  prompt = ChatPromptTemplate.from_template(template)
@@ -92,8 +88,8 @@ def set_up_chat_ui():
92
  random.choice(APP_TEXT['ai_greetings'])
93
  )
94
 
95
- # for msg in history.messages:
96
- # st.chat_message(msg.type).write(msg.content)
97
 
98
  progress_bar.progress(100, text='Done!')
99
  progress_bar.empty()
 
39
  Display content in the page footer.
40
  """
41
 
42
+ st.text(APP_TEXT['tos'] + '\n\n' + APP_TEXT['tos2'])
43
  # st.markdown(
44
  # '![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fbarunsaha%2Fslide-deck-ai&countColor=%23263759)' # noqa: E501
45
  # )
 
67
  history = StreamlitChatMessageHistory(key='chat_messages')
68
  llm = llm_helper.get_hf_endpoint()
69
 
70
+ with open(GlobalConfig.CHAT_TEMPLATE_FILE, 'r', encoding='utf-8') as in_file:
 
 
 
 
71
  template = in_file.read()
72
 
73
  prompt = ChatPromptTemplate.from_template(template)
 
88
  random.choice(APP_TEXT['ai_greetings'])
89
  )
90
 
91
+ for msg in history.messages:
92
+ st.chat_message(msg.type).markdown(msg.content)
93
 
94
  progress_bar.progress(100, text='Done!')
95
  progress_bar.empty()
global_config.py CHANGED
@@ -24,6 +24,7 @@ class GlobalConfig:
24
  PRELOAD_DATA_FILE = 'examples/example_02.json'
25
  SLIDES_TEMPLATE_FILE = 'langchain_templates/template_combined.txt'
26
  JSON_TEMPLATE_FILE = 'langchain_templates/text_to_json_template_02.txt'
 
27
 
28
  PPTX_TEMPLATE_FILES = {
29
  'Blank': {
 
24
  PRELOAD_DATA_FILE = 'examples/example_02.json'
25
  SLIDES_TEMPLATE_FILE = 'langchain_templates/template_combined.txt'
26
  JSON_TEMPLATE_FILE = 'langchain_templates/text_to_json_template_02.txt'
27
+ CHAT_TEMPLATE_FILE = 'langchain_templates/template_combined_chat_history.txt'
28
 
29
  PPTX_TEMPLATE_FILES = {
30
  'Blank': {
langchain_templates/template_combined_chat_history.txt ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are a helpful, intelligent chatbot. Follow the instructions and chat history, if available, to create or revise the slides for a presentation on the given topic.
2
+ Include main headings for each slide, detailed bullet points for each slide.
3
+ Add relevant content to each slide.
4
+ The content should be descriptive, verbose, and detailed as much as possible.
5
+ If relevant, add one or two examples to illustrate the concept.
6
+ Unless explicitly specified with the topic, create about 10 slides.
7
+
8
+
9
+ ### Instructions:
10
+ {question}
11
+
12
+
13
+ ### Chat history:
14
+ {chat_history}
15
+
16
+
17
+ The output should only be JSON and nothing else.
18
+ The desired JSON output format:
19
+ {{
20
+ "title": "Presentation Title",
21
+ "slides": [
22
+ {{
23
+ "heading": "Heading for the First Slide",
24
+ "bullet_points": [
25
+ "First bullet point",
26
+ [
27
+ "Sub-bullet point 1",
28
+ "Sub-bullet point 2"
29
+ ],
30
+ "Second bullet point"
31
+ ]
32
+ }},
33
+ {{
34
+ "heading": "Heading for the Second Slide",
35
+ "bullet_points": [
36
+ "First bullet point",
37
+ "Second bullet item",
38
+ "Third bullet point"
39
+ ]
40
+ }}
41
+ ]
42
+ }}
43
+
44
+
45
+ ### Output:
46
+ ```json