mckplus commited on
Commit
53c0aaf
1 Parent(s): e5b907c

Update DocuChat.py

Browse files
Files changed (1) hide show
  1. DocuChat.py +12 -4
DocuChat.py CHANGED
@@ -7,6 +7,7 @@ from langchain.text_splitter import CharacterTextSplitter
7
  from langchain.embeddings import OpenAIEmbeddings
8
  from langchain.vectorstores import Chroma
9
  import panel as pn
 
10
 
11
  # Custom CSS to use Lato font
12
  lato_font_style = """
@@ -15,7 +16,8 @@ lato_font_style = """
15
  }
16
  """
17
 
18
- pn.state.template.param.update(
 
19
  raw_css=[lato_font_style],
20
  css_files=['https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap']
21
  )
@@ -71,7 +73,7 @@ class LangchainConversation:
71
  self.chat_history.append((query, result['result']))
72
 
73
  return result['result']
74
-
75
  def view(self):
76
  custom_link_style = {
77
  'color': '#1b9aaa',
@@ -90,8 +92,14 @@ class LangchainConversation:
90
  Built by <a href="https://www.mckenzielloydsmith.com/home?utm_source=HuggingFace&utm_medium=PDF+Analyzer" style="color:#1b9aaa;font-weight:bold;">McKenzie</a>.
91
  """, styles=custom_link_style),
92
  pn.Row(self.file_input, self.openaikey), self.chatbox
93
- ).servable()
94
- return layout
 
 
 
 
 
 
95
 
96
  langchain_conversation = LangchainConversation()
97
  langchain_conversation.view()
 
7
  from langchain.embeddings import OpenAIEmbeddings
8
  from langchain.vectorstores import Chroma
9
  import panel as pn
10
+ from panel.template import VanillaTemplate
11
 
12
  # Custom CSS to use Lato font
13
  lato_font_style = """
 
16
  }
17
  """
18
 
19
+ # Create a custom template
20
+ template = VanillaTemplate(
21
  raw_css=[lato_font_style],
22
  css_files=['https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap']
23
  )
 
73
  self.chat_history.append((query, result['result']))
74
 
75
  return result['result']
76
+
77
  def view(self):
78
  custom_link_style = {
79
  'color': '#1b9aaa',
 
92
  Built by <a href="https://www.mckenzielloydsmith.com/home?utm_source=HuggingFace&utm_medium=PDF+Analyzer" style="color:#1b9aaa;font-weight:bold;">McKenzie</a>.
93
  """, styles=custom_link_style),
94
  pn.Row(self.file_input, self.openaikey), self.chatbox
95
+ )
96
+
97
+ # Add layout to the template
98
+ template.main.append(layout)
99
+
100
+ # Serve the template
101
+ return template.servable()
102
+
103
 
104
  langchain_conversation = LangchainConversation()
105
  langchain_conversation.view()