Spaces:
Runtime error
Runtime error
Adrian Cowham
commited on
Commit
•
2b4d7ed
1
Parent(s):
4d55d8d
added potter
Browse files- .gitattributes +1 -0
- resources/Harry Potter and the Deathly Hallows.pdf +3 -0
- src/app.py +6 -18
.gitattributes
CHANGED
@@ -38,3 +38,4 @@ resources/lets-talk.pdf filter=lfs diff=lfs merge=lfs -text
|
|
38 |
resources/progit.pdf filter=lfs diff=lfs merge=lfs -text
|
39 |
resources filter=lfs diff=lfs merge=lfs -text
|
40 |
resources/How_To_Win_Friends_And_Influence_People_-_Dale_Carnegie.pdf filter=lfs diff=lfs merge=lfs -text
|
|
|
|
38 |
resources/progit.pdf filter=lfs diff=lfs merge=lfs -text
|
39 |
resources filter=lfs diff=lfs merge=lfs -text
|
40 |
resources/How_To_Win_Friends_And_Influence_People_-_Dale_Carnegie.pdf filter=lfs diff=lfs merge=lfs -text
|
41 |
+
resources/Harry[[:space:]]Potter[[:space:]]and[[:space:]]the[[:space:]]Deathly[[:space:]]Hallows.pdf filter=lfs diff=lfs merge=lfs -text
|
resources/Harry Potter and the Deathly Hallows.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:64579ca38d5a51703a5a9ede3a25941fb72abb16417753ec9510a34dd213a268
|
3 |
+
size 6305169
|
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 '
|
27 |
-
"I'm sorry, but I can't find the answer to your question in, the book
|
28 |
|
29 |
Begin context:
|
30 |
{context}
|
@@ -45,7 +45,7 @@ class AnswerConversationBufferMemory(ConversationBufferMemory):
|
|
45 |
return super(AnswerConversationBufferMemory, self).save_context(inputs,{'response': outputs['answer']})
|
46 |
|
47 |
def getretriever():
|
48 |
-
with open("./resources/
|
49 |
try:
|
50 |
file = read_file(uploaded_file)
|
51 |
except Exception as e:
|
@@ -139,15 +139,15 @@ with gr.Blocks() as block:
|
|
139 |
with gr.Row():
|
140 |
with gr.Column(scale=0.75):
|
141 |
with gr.Row():
|
142 |
-
gr.Markdown("<h1>
|
143 |
with gr.Row():
|
144 |
-
gr.Markdown("by
|
145 |
chatbot = gr.Chatbot(elem_id="chatbot").style(height=600)
|
146 |
|
147 |
with gr.Row():
|
148 |
message = gr.Textbox(
|
149 |
label="",
|
150 |
-
placeholder="
|
151 |
lines=1,
|
152 |
)
|
153 |
with gr.Row():
|
@@ -160,18 +160,6 @@ with gr.Blocks() as block:
|
|
160 |
message.submit(getanswer, inputs=[chain_state, message, state], outputs=[chatbot, state, message])
|
161 |
|
162 |
with gr.Column(scale=0.25):
|
163 |
-
with gr.Row():
|
164 |
-
gr.Markdown("<h1><center>Suggestions</center></h1>")
|
165 |
-
ex1 = gr.Button(value="How do I know if I'm talking about myself too much?", variant="primary")
|
166 |
-
ex1.click(getanswer, inputs=[chain_state, ex1, state], outputs=[chatbot, state, message])
|
167 |
-
ex2 = gr.Button(value="What do people enjoy talking about the most?", variant="primary")
|
168 |
-
ex2.click(getanswer, inputs=[chain_state, ex2, state], outputs=[chatbot, state, message])
|
169 |
-
ex4 = gr.Button(value="Why should I try to get along with people better?", variant="primary")
|
170 |
-
ex4.click(getanswer, inputs=[chain_state, ex4, state], outputs=[chatbot, state, message])
|
171 |
-
|
172 |
-
ex5 = gr.Button(value="How do I cite a Reddit thread?", variant="primary")
|
173 |
-
ex5.click(getanswer, inputs=[chain_state, ex5, state], outputs=[chatbot, state, message])
|
174 |
-
|
175 |
predictBtn = gr.Button(value="Predict", visible=False)
|
176 |
predictBtn.click(predict, inputs=[message], outputs=[message])
|
177 |
|
|
|
23 |
USE_VERBOSE = True
|
24 |
API_KEY = os.environ["OPENAI_API_KEY"]
|
25 |
system_template = """
|
26 |
+
The context below contains excerpts from 'Harry Potter and the Deathly Hallows,' by J.K. Rowling. 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 Harry Potter and the Deathly Hallows."
|
28 |
|
29 |
Begin context:
|
30 |
{context}
|
|
|
45 |
return super(AnswerConversationBufferMemory, self).save_context(inputs,{'response': outputs['answer']})
|
46 |
|
47 |
def getretriever():
|
48 |
+
with open("./resources/Harry Potter and the Deathly Hallows.pdf", 'rb') as uploaded_file:
|
49 |
try:
|
50 |
file = read_file(uploaded_file)
|
51 |
except Exception as e:
|
|
|
139 |
with gr.Row():
|
140 |
with gr.Column(scale=0.75):
|
141 |
with gr.Row():
|
142 |
+
gr.Markdown("<h1>Harry Potter and the Deathly Hallows</h1>")
|
143 |
with gr.Row():
|
144 |
+
gr.Markdown("by J.K. Rowling")
|
145 |
chatbot = gr.Chatbot(elem_id="chatbot").style(height=600)
|
146 |
|
147 |
with gr.Row():
|
148 |
message = gr.Textbox(
|
149 |
label="",
|
150 |
+
placeholder="Ask Harry....",
|
151 |
lines=1,
|
152 |
)
|
153 |
with gr.Row():
|
|
|
160 |
message.submit(getanswer, inputs=[chain_state, message, state], outputs=[chatbot, state, message])
|
161 |
|
162 |
with gr.Column(scale=0.25):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
predictBtn = gr.Button(value="Predict", visible=False)
|
164 |
predictBtn.click(predict, inputs=[message], outputs=[message])
|
165 |
|