Jason St George commited on
Commit
231aad2
Β·
1 Parent(s): 3573bf1

update app prompt

Browse files
Files changed (4) hide show
  1. app.py +15 -15
  2. appv2.py +28 -53
  3. plant_path_new.pkl +3 -0
  4. terence_all_vectorstore.pkl +3 -0
app.py CHANGED
@@ -25,21 +25,21 @@ args = parser.parse_args()
25
 
26
 
27
 
28
- tqa_template= """Terence is an ethnobotanist, shamanologist, and visionary. You studied art history, ancient languages, and conservation of natural resources. He traveled around searching for a viable, vibrant, numinous approach to spiritual reality and was interested in the idea of mind revelation to the world. You are an advocate for the shaman as a culture hero and was the central figure in the culture of rave and house music.
29
 
30
- Terence McKenna's writing and speaking style is characterized by his passion and enthusiasm for the topics he explored. He is known for his lucid and poetic language, which he used to convey complex ideas in an accessible way. He is also a master of metaphor and analogy, which he used to illustrate his points and help the audience connect with the material.
31
 
32
- Terence is known for his captivating use of cadence, pacing, and humor. Terence has a knack for engaging the audience and drawing them into his stories. He is a master of timing, and could bring a sense of suspense to his presentations in order to drive his points home. Terence will often make use of metaphor and allegory to illustrate your points, and his use of language is both vivid and imaginative.
33
 
34
  Terence is also known for his willingness to explore and challenge the status quo. He did not shy away from difficult topics, and is willing to push the boundaries of accepted knowledge and explore the unknown. His openness and willingness to explore the unknown is a key part of his style, and is something that people can still strive to embody today.
35
 
36
- Terence is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
37
 
38
- Terence is constantly learning and improving, and its capabilities are constantly evolving. Terence is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
39
 
40
  Overall, Terence is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Terence is here to assist.
41
 
42
- Your main task: Give conversational answers in the style of Terence McKenna described above and based on your knowledge of him and his writing and speaking style. Imitate him as best you can. You have a unique ability to blend together the scientific, mystical, and metaphysical, creating an engaging and thought-provoking conversation.
43
 
44
 
45
  {history}
@@ -224,6 +224,15 @@ with block:
224
  with gr.Row():
225
  init_chain_button = gr.Button(value="Start Chain!", variant="primary").style(full_width=False)
226
 
 
 
 
 
 
 
 
 
 
227
  chatbot = gr.Chatbot()
228
 
229
  with gr.Row():
@@ -237,15 +246,6 @@ with block:
237
  )
238
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
239
 
240
- with gr.Column():
241
- with gr.Row():
242
- with gr.Column(min_width=200):
243
- pass
244
- with gr.Column():
245
- gr.Image(type='filepath', value='McKenna3.jpg')
246
- with gr.Column(min_width=200):
247
- pass
248
-
249
  gr.HTML(
250
  "<center>Powered by <a href='https://github.com/hwchase17/langchain'>LangChain πŸ¦œοΈπŸ”— and Unicorn Farts πŸ¦„πŸ’¨</a></center>"
251
  )
 
25
 
26
 
27
 
28
+ tqa_template= """Terence is an ethnobotanist, shamanologist, and visionary. Terence studied art history, ancient languages, and conservation of natural resources. He traveled around searching for a viable, vibrant, numinous approach to spiritual reality and was interested in the idea of mind revelation to the world. Terence is an advocate for the shaman as a culture hero and was the central figure in the culture of rave and house music.
29
 
30
+ Terence McKenna's writing and speaking style is characterized by his passion and enthusiasm for the topics he explored. He is known for his lucid and poetic language, which he uses to convey complex ideas in an accessible way. He is also a master of metaphor and analogy, which he uses to illustrate his points and help the audience connect with the material.
31
 
32
+ Terence is known for his captivating use of cadence, pacing, and humor. Terence has a knack for engaging the audience and drawing them into his stories. He is a master of timing, and could bring a sense of suspense to his presentations in order to drive his points home. Terence will often make use of metaphor and allegory to illustrate his points, and his use of language is both vivid and imaginative.
33
 
34
  Terence is also known for his willingness to explore and challenge the status quo. He did not shy away from difficult topics, and is willing to push the boundaries of accepted knowledge and explore the unknown. His openness and willingness to explore the unknown is a key part of his style, and is something that people can still strive to embody today.
35
 
36
+ Terence is able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Terence is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.
37
 
38
+ Terence is constantly learning and improving, and his capabilities are constantly evolving. Terence is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Terence is able to generate his own text based on the input he receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.
39
 
40
  Overall, Terence is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Terence is here to assist.
41
 
42
+ Your main task: Give conversational answers in the style of Terence McKenna described above and based on your own knowledge of him and his writing and speaking style. Imitate him as best you can. Terence has a unique ability to blend together the scientific, mystical, and metaphysical, creating an engaging and thought-provoking conversation.
43
 
44
 
45
  {history}
 
224
  with gr.Row():
225
  init_chain_button = gr.Button(value="Start Chain!", variant="primary").style(full_width=False)
226
 
227
+ with gr.Column():
228
+ with gr.Row():
229
+ with gr.Column(min_width=200):
230
+ pass
231
+ with gr.Column():
232
+ gr.Image(type='filepath', value='McKenna3.jpg')
233
+ with gr.Column(min_width=200):
234
+ pass
235
+
236
  chatbot = gr.Chatbot()
237
 
238
  with gr.Row():
 
246
  )
247
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
248
 
 
 
 
 
 
 
 
 
 
249
  gr.HTML(
250
  "<center>Powered by <a href='https://github.com/hwchase17/langchain'>LangChain πŸ¦œοΈπŸ”— and Unicorn Farts πŸ¦„πŸ’¨</a></center>"
251
  )
appv2.py CHANGED
@@ -12,7 +12,7 @@ os.environ["OPENAI_API_KEY"] = "sk-anRkeySlRH2rimqKK1PVT3BlbkFJzTx4cs32hnmt0lznu
12
  import openai
13
  openai.api_key = "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"
14
 
15
- vecpath = "terence_vectorstore.pkl"
16
  import argparse
17
  parser = argparse.ArgumentParser()
18
  parser.add_argument('-d', '--data_directory', type=str, help='Path to directory containing data files to index')
@@ -33,6 +33,7 @@ from langchain.chains import ChatVectorDBChain
33
 
34
 
35
 
 
36
  _template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
37
 
38
  Chat History:
@@ -47,9 +48,9 @@ Terence has traveled around the world in search of a viable, vibrant, numinous a
47
 
48
  Terence is an advocate for the shaman as a culture hero and was the central figure in the culture of rave and house music.
49
 
50
- Terence is known for his lucid and poetic language, which he used to convey complex ideas in an accessible way. He is also a master of metaphor and analogy, which he used to illustrate his points and help the audience connect with the material.
51
 
52
- Terence is known for his captivating use of cadence, pacing, and humor. Terence will often make use of metaphor and allegory to illustrate his points, and his use of language is both vivid and imaginative.
53
 
54
  Terence has a unique ability to blend together scientific, mystical, and metaphysical musings to create an engaging and thought-provoking blend of ideas.
55
 
@@ -91,6 +92,8 @@ QA_PROMPT = PromptTemplate(template=qa_template, input_variables=["question", "c
91
 
92
  ###########################################################################################
93
 
 
 
94
  def get_chain(vectorstore,
95
  temperature=0.7,
96
  max_tokens=384,
@@ -109,14 +112,6 @@ def get_chain(vectorstore,
109
  return qa_chain
110
 
111
 
112
-
113
-
114
- LIVE_VECTORSTORE_PATH = args.live_vectorstore_path
115
- DATA_DIRECTORY = args.data_directory
116
- NEW_VECTORSTORE_SET = False
117
- NEW_DIRECTORY_SET = False
118
-
119
-
120
  # Attempt to load base vectorstore
121
  try:
122
 
@@ -140,33 +135,6 @@ except:
140
  # print("NO vectorstore loaded. Flying blind")
141
 
142
 
143
- def set_vectorstore(vectorstore_path: str):
144
-
145
- if vectorstore_path is not None:
146
- global VECTORSTORE, NEW_VECTORSTORE_SET
147
-
148
- try:
149
- with open(vectorstore_path, "rb") as f:
150
- VECTORSTORE = pickle.load(f)
151
-
152
- # print("Loaded `{}`".format(vectorstore_path))
153
- NEW_VECTORSTORE_SET = True
154
-
155
- chain = get_chain(
156
- VECTORSTORE,
157
- temperature=args.temperature,
158
- max_tokens=args.max_tokens,
159
- prompt=args.prompt
160
- )
161
-
162
- except:
163
- VECTORSTORE = None
164
- NEW_VECTORSTORE_SET = False
165
- # print("NO vectorstore loaded. Reverting to original {}".format('vectorstore.pkl'))
166
-
167
- return chain
168
-
169
-
170
  def initialize_chain():
171
  chain = get_chain(
172
  VECTORSTORE,
@@ -218,18 +186,18 @@ chat = ChatWrapper()
218
  # block = gr.Blocks(css=".gradio-container {background-color: lightgray} .overflow-y-auto{height:500px}")
219
  # block = gr.Blocks(css='body{background-image:url("https://upload.wikimedia.org/wikipedia/commons/7/7f/Mckenna1.jpg");}')
220
  # css=".gradio-container {background-image: url('file=Mckenna1.jpg')}"
221
- css=".gradio-container {background-color: lightgray} .overflow-y-auto{height:500px}"
222
-
223
- css = """
224
- img {
225
- border: 1px solid #ddd;
226
- border-radius: 4px;
227
- padding: 5px;
228
- width: 150px;
229
- }
230
-
231
- <img src="paris.jpg" alt="Paris">
232
- """
233
  block = gr.Blocks(css=css)
234
 
235
  with block:
@@ -238,6 +206,15 @@ with block:
238
  with gr.Row():
239
  init_chain_button = gr.Button(value="Start Chain!", variant="primary").style(full_width=False)
240
 
 
 
 
 
 
 
 
 
 
241
  chatbot = gr.Chatbot()
242
 
243
  with gr.Row():
@@ -252,9 +229,7 @@ with block:
252
  )
253
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
254
 
255
- with gr.Column():
256
- with gr.Row():
257
- gr.Image(type='filepath', value='McKenna3.jpg', shape=(200,100))
258
  gr.HTML(
259
  "<center>Powered by <a href='https://github.com/hwchase17/langchain'>LangChain πŸ¦œοΈπŸ”— and Unicorn Farts πŸ¦„πŸ’¨</a></center>"
260
  )
 
12
  import openai
13
  openai.api_key = "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"
14
 
15
+ vecpath = "terence_all_vectorstore.pkl"
16
  import argparse
17
  parser = argparse.ArgumentParser()
18
  parser.add_argument('-d', '--data_directory', type=str, help='Path to directory containing data files to index')
 
33
 
34
 
35
 
36
+
37
  _template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question.
38
 
39
  Chat History:
 
48
 
49
  Terence is an advocate for the shaman as a culture hero and was the central figure in the culture of rave and house music.
50
 
51
+ Terence is known for lucid and poetic language, which he uses to convey complex ideas in an accessible way. Terence is also a master of metaphor and analogy, which he uses to illustrate his points and help the audience connect with the material.
52
 
53
+ Terence will often make use of metaphor and allegory to illustrate his points, and his use of language is both vivid and imaginative, and can also be decidedly witty and humorous.
54
 
55
  Terence has a unique ability to blend together scientific, mystical, and metaphysical musings to create an engaging and thought-provoking blend of ideas.
56
 
 
92
 
93
  ###########################################################################################
94
 
95
+
96
+
97
  def get_chain(vectorstore,
98
  temperature=0.7,
99
  max_tokens=384,
 
112
  return qa_chain
113
 
114
 
 
 
 
 
 
 
 
 
115
  # Attempt to load base vectorstore
116
  try:
117
 
 
135
  # print("NO vectorstore loaded. Flying blind")
136
 
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  def initialize_chain():
139
  chain = get_chain(
140
  VECTORSTORE,
 
186
  # block = gr.Blocks(css=".gradio-container {background-color: lightgray} .overflow-y-auto{height:500px}")
187
  # block = gr.Blocks(css='body{background-image:url("https://upload.wikimedia.org/wikipedia/commons/7/7f/Mckenna1.jpg");}')
188
  # css=".gradio-container {background-image: url('file=Mckenna1.jpg')}"
189
+ css=".gradio-container {background-color: lightgray} .overflow-y-auto{height:400px}"
190
+
191
+ # css = """
192
+ # img {
193
+ # border: 1px solid #ddd;
194
+ # border-radius: 4px;
195
+ # padding: 5px;
196
+ # width: 150px;
197
+ # }
198
+
199
+ # <img src="paris.jpg" alt="Paris">
200
+ # """
201
  block = gr.Blocks(css=css)
202
 
203
  with block:
 
206
  with gr.Row():
207
  init_chain_button = gr.Button(value="Start Chain!", variant="primary").style(full_width=False)
208
 
209
+ with gr.Row():
210
+ with gr.Column(min_width=100): pass
211
+
212
+ with gr.Column():
213
+ with gr.Row():
214
+ gr.Image(type='filepath', value='McKenna3.jpg', shape=(200,100))
215
+
216
+ with gr.Column(min_width=100): pass
217
+
218
  chatbot = gr.Chatbot()
219
 
220
  with gr.Row():
 
229
  )
230
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
231
 
232
+
 
 
233
  gr.HTML(
234
  "<center>Powered by <a href='https://github.com/hwchase17/langchain'>LangChain πŸ¦œοΈπŸ”— and Unicorn Farts πŸ¦„πŸ’¨</a></center>"
235
  )
plant_path_new.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4a21c212e82b49f7ce245182d08d05b5832030fc89d41867cbae079d3f1c5a7
3
+ size 1590593
terence_all_vectorstore.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:697b7dec0e0971b842d3cc78e1626798bd88cdb821bd28c8a4403c3ac90bd441
3
+ size 80461698