Adrian Cowham commited on
Commit
1fa049e
Β·
1 Parent(s): 0c47d68
Files changed (2) hide show
  1. README.md +4 -4
  2. src/app.py +15 -16
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Pyrocene
3
- emoji: πŸŒ–
4
- colorFrom: green
5
- colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.40.1
8
  app_file: src/app.py
 
1
  ---
2
+ title: Let's Talk...
3
+ emoji: πŸ“•
4
+ colorFrom: red
5
+ colorTo: white
6
  sdk: gradio
7
  sdk_version: 3.40.1
8
  app_file: src/app.py
src/app.py CHANGED
@@ -23,8 +23,8 @@ K = 5
23
  USE_VERBOSE = True
24
  API_KEY = os.environ["OPENAI_API_KEY"]
25
  system_template = """
26
- The context below contains excerpts from 'Design by Fire,' by Emily Elizabeth Schlickman and Brett Milligan. You must only use the information in the context below to formulate your response. If there is not enough information to formulate a response, you must respond with
27
- "I'm sorry, but I can't find the answer to your question in, the book Design by Fire."
28
 
29
  Here is the context:
30
  {context}
@@ -43,7 +43,7 @@ class AnswerConversationBufferMemory(ConversationBufferMemory):
43
  return super(AnswerConversationBufferMemory, self).save_context(inputs,{'response': outputs['answer']})
44
 
45
  def getretriever():
46
- with open("./resources/design-by-fire.pdf", 'rb') as uploaded_file:
47
  try:
48
  file = read_file(uploaded_file)
49
  except Exception as e:
@@ -95,26 +95,19 @@ def load_chain(inputs = None):
95
  combine_docs_chain_kwargs={"prompt": qa_prompt})
96
  return chain
97
 
98
- CSS ="""
99
- .contain { display: flex; flex-direction: column; }
100
- .gradio-container { height: 100vh !important; }
101
- #component-0 { height: 100%; }
102
- #chatbot { flex-grow: 1; overflow: auto;}
103
- """
104
-
105
  with gr.Blocks() as block:
106
  with gr.Row():
107
  with gr.Column(scale=0.75):
108
  with gr.Row():
109
- gr.Markdown("<h1>Design by Fire</h1>")
110
  with gr.Row():
111
- gr.Markdown("by Emily Elizabeth Schlickman and Brett Milligan")
112
  chatbot = gr.Chatbot(elem_id="chatbot").style(height=600)
113
 
114
  with gr.Row():
115
  message = gr.Textbox(
116
  label="",
117
- placeholder="Design by Fire",
118
  lines=1,
119
  )
120
  with gr.Row():
@@ -129,11 +122,17 @@ with gr.Blocks() as block:
129
  with gr.Column(scale=0.25):
130
  with gr.Row():
131
  gr.Markdown("<h1><center>Suggestions</center></h1>")
132
- ex1 = gr.Button(value="What are the main factors and trends discussed in the book that contribute to the changing behavior of wildfires?", variant="primary")
133
  ex1.click(getanswer, inputs=[chain_state, ex1, state], outputs=[chatbot, state, message])
134
- ex2 = gr.Button(value="How does the book explore the relationship between fire and different landscapes, such as wilderness and urban areas?", variant="primary")
135
  ex2.click(getanswer, inputs=[chain_state, ex2, state], outputs=[chatbot, state, message])
136
- ex3 = gr.Button(value="What are the three approaches to designing with fire that the book presents?", variant="primary")
137
  ex3.click(getanswer, inputs=[chain_state, ex3, state], outputs=[chatbot, state, message])
138
 
 
 
 
 
 
 
139
  block.launch(debug=True)
 
23
  USE_VERBOSE = True
24
  API_KEY = os.environ["OPENAI_API_KEY"]
25
  system_template = """
26
+ The context below contains excerpts from 'Let's Talk,' by Emily Elizabeth Schlickman and Brett Milligan. You must only use the information in the context below to formulate your response. If there is not enough information to formulate a response, you must respond with
27
+ "I'm sorry, but I can't find the answer to your question in, the book Let's Talk..."
28
 
29
  Here is the context:
30
  {context}
 
43
  return super(AnswerConversationBufferMemory, self).save_context(inputs,{'response': outputs['answer']})
44
 
45
  def getretriever():
46
+ with open("./resources/lets-talk.pdf", 'rb') as uploaded_file:
47
  try:
48
  file = read_file(uploaded_file)
49
  except Exception as e:
 
95
  combine_docs_chain_kwargs={"prompt": qa_prompt})
96
  return chain
97
 
 
 
 
 
 
 
 
98
  with gr.Blocks() as block:
99
  with gr.Row():
100
  with gr.Column(scale=0.75):
101
  with gr.Row():
102
+ gr.Markdown("<h1>Let's Talk...</h1>")
103
  with gr.Row():
104
+ gr.Markdown("by Andrea Lunsford")
105
  chatbot = gr.Chatbot(elem_id="chatbot").style(height=600)
106
 
107
  with gr.Row():
108
  message = gr.Textbox(
109
  label="",
110
+ placeholder="Let's Talk...",
111
  lines=1,
112
  )
113
  with gr.Row():
 
122
  with gr.Column(scale=0.25):
123
  with gr.Row():
124
  gr.Markdown("<h1><center>Suggestions</center></h1>")
125
+ ex1 = gr.Button(value="How can I make myself be heard?", variant="primary")
126
  ex1.click(getanswer, inputs=[chain_state, ex1, state], outputs=[chatbot, state, message])
127
+ ex2 = gr.Button(value="How can I connect with people I disagree with?", variant="primary")
128
  ex2.click(getanswer, inputs=[chain_state, ex2, state], outputs=[chatbot, state, message])
129
+ ex3 = gr.Button(value="How do I come up with ideas for my essay?", variant="primary")
130
  ex3.click(getanswer, inputs=[chain_state, ex3, state], outputs=[chatbot, state, message])
131
 
132
+ ex4 = gr.Button(value="My professor reviewed my first draft. She circled a sentence and said I need to support it more. How do I do that?", variant="primary")
133
+ ex4.click(getanswer, inputs=[chain_state, ex4, state], outputs=[chatbot, state, message])
134
+
135
+ ex5 = gr.Button(value="How do I cite a Reddit thread?", variant="primary")
136
+ ex5.click(getanswer, inputs=[chain_state, ex5, state], outputs=[chatbot, state, message])
137
+
138
  block.launch(debug=True)