Spaces:
Sleeping
Sleeping
Commit
·
e2b4917
1
Parent(s):
bcc7659
adding chatbot with advanced options
Browse files
app.py
CHANGED
@@ -11,7 +11,10 @@ from langchain.prompts import PromptTemplate
|
|
11 |
|
12 |
DEVICE = 'cpu'
|
13 |
FILE_EXT = ['pdf','text','csv','word','wav']
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
def loading_file():
|
17 |
return "Loading..."
|
@@ -164,15 +167,33 @@ with gr.Blocks(css=css) as demo:
|
|
164 |
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
165 |
load_pdf.click(document_loader, inputs=[pdf_doc,API_key,file_extension,LLM_option], outputs=[langchain_status], queue=False)
|
166 |
|
167 |
-
with gr.
|
168 |
-
|
169 |
-
|
170 |
-
sources = gr.HTML(value = "Source paragraphs where I looked for answers will appear here", height=300)
|
171 |
-
|
172 |
with gr.Row():
|
173 |
question = gr.Textbox(label="Type your question?",lines=1).style(full_width=False)
|
174 |
-
submit_btn = gr.Button(value="Send message", variant="
|
175 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
176 |
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
demo.launch()
|
|
|
11 |
|
12 |
DEVICE = 'cpu'
|
13 |
FILE_EXT = ['pdf','text','csv','word','wav']
|
14 |
+
DEFAULT_SYSTEM_PROMPT = "As a chatbot you are answering set of questions being requested ."
|
15 |
+
MAX_MAX_NEW_TOKENS = 2048
|
16 |
+
DEFAULT_MAX_NEW_TOKENS = 1024
|
17 |
+
MAX_INPUT_TOKEN_LENGTH = 4000
|
18 |
|
19 |
def loading_file():
|
20 |
return "Loading..."
|
|
|
167 |
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
168 |
load_pdf.click(document_loader, inputs=[pdf_doc,API_key,file_extension,LLM_option], outputs=[langchain_status], queue=False)
|
169 |
|
170 |
+
with gr.Group():
|
171 |
+
chatbot = gr.Chatbot(height=300)
|
172 |
+
# with gr.Row():
|
173 |
+
# sources = gr.HTML(value = "Source paragraphs where I looked for answers will appear here", height=300)
|
|
|
174 |
with gr.Row():
|
175 |
question = gr.Textbox(label="Type your question?",lines=1).style(full_width=False)
|
176 |
+
submit_btn = gr.Button(value="Send message", variant="primary", scale = 1)
|
177 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
178 |
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
179 |
|
180 |
+
with gr.Accordion(label='Advanced options', open=False):
|
181 |
+
system_prompt = gr.Textbox(label='System prompt',
|
182 |
+
value=DEFAULT_SYSTEM_PROMPT,
|
183 |
+
lines=6)
|
184 |
+
max_new_tokens = gr.Slider(
|
185 |
+
label='Max new tokens',
|
186 |
+
minimum=1,
|
187 |
+
maximum=MAX_MAX_NEW_TOKENS,
|
188 |
+
step=1,
|
189 |
+
value=DEFAULT_MAX_NEW_TOKENS,
|
190 |
+
)
|
191 |
+
temperature = gr.Slider(
|
192 |
+
label='Temperature',
|
193 |
+
minimum=0.1,
|
194 |
+
maximum=4.0,
|
195 |
+
step=0.1,
|
196 |
+
value=1.0,
|
197 |
+
)
|
198 |
+
|
199 |
demo.launch()
|