Spaces:
Sleeping
Sleeping
Commit
·
a5b8a59
1
Parent(s):
b04aa25
Adding chat clear button
Browse files
app.py
CHANGED
@@ -48,9 +48,6 @@ def chat_application(llm_service,key,temperature=0.1,max_tokens=1024):
|
|
48 |
llm = get_openai_chat_model(API_key=key)
|
49 |
return llm
|
50 |
|
51 |
-
def summarize_contents():
|
52 |
-
question = "Generate a summary of the contents. Do not return the response in json format"
|
53 |
-
return qa.run(question)
|
54 |
|
55 |
def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface',temperature=0.1,max_tokens=4096):
|
56 |
document = None
|
@@ -104,6 +101,10 @@ def process_pdf_document(document_file):
|
|
104 |
document = loader.load()
|
105 |
return document
|
106 |
|
|
|
|
|
|
|
|
|
107 |
def infer(question, history):
|
108 |
# res = []
|
109 |
# # for human, ai in history[:-1]:
|
@@ -155,13 +156,13 @@ with gr.Blocks(css=css) as demo:
|
|
155 |
with gr.Row():
|
156 |
question = gr.Textbox(label="Type your question?",lines=1).style(full_width=False)
|
157 |
submit_btn = gr.Button(value="Send message", variant="primary", scale = 1)
|
|
|
158 |
|
159 |
with gr.Column():
|
160 |
with gr.Box():
|
161 |
LLM_option = gr.Dropdown(['HuggingFace','OpenAI'],label='Large Language Model Selection',info='LLM Service')
|
162 |
API_key = gr.Textbox(label="Add API key", type="password")
|
163 |
-
|
164 |
-
|
165 |
with gr.Column():
|
166 |
with gr.Box():
|
167 |
file_extension = gr.Dropdown(FILE_EXT, label="File Extensions", info="Select type of file to upload !")
|
@@ -189,11 +190,13 @@ with gr.Blocks(css=css) as demo:
|
|
189 |
# question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
190 |
# submit_button = gr.Button("Send Message")
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
197 |
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
|
|
|
|
198 |
|
199 |
demo.launch()
|
|
|
48 |
llm = get_openai_chat_model(API_key=key)
|
49 |
return llm
|
50 |
|
|
|
|
|
|
|
51 |
|
52 |
def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface',temperature=0.1,max_tokens=4096):
|
53 |
document = None
|
|
|
101 |
document = loader.load()
|
102 |
return document
|
103 |
|
104 |
+
|
105 |
+
def clear_chat():
|
106 |
+
return []
|
107 |
+
|
108 |
def infer(question, history):
|
109 |
# res = []
|
110 |
# # for human, ai in history[:-1]:
|
|
|
156 |
with gr.Row():
|
157 |
question = gr.Textbox(label="Type your question?",lines=1).style(full_width=False)
|
158 |
submit_btn = gr.Button(value="Send message", variant="primary", scale = 1)
|
159 |
+
clean_chat = gr.Button(Value = "Clear chat", variant="primary", scale = 1)
|
160 |
|
161 |
with gr.Column():
|
162 |
with gr.Box():
|
163 |
LLM_option = gr.Dropdown(['HuggingFace','OpenAI'],label='Large Language Model Selection',info='LLM Service')
|
164 |
API_key = gr.Textbox(label="Add API key", type="password")
|
165 |
+
|
|
|
166 |
with gr.Column():
|
167 |
with gr.Box():
|
168 |
file_extension = gr.Dropdown(FILE_EXT, label="File Extensions", info="Select type of file to upload !")
|
|
|
190 |
# question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
191 |
# submit_button = gr.Button("Send Message")
|
192 |
|
193 |
+
if pdf_doc:
|
194 |
+
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
195 |
+
load_pdf.click(document_loader, inputs=[pdf_doc,API_key,file_extension,LLM_option,temperature,max_new_tokens], outputs=[langchain_status], queue=False)
|
196 |
+
|
197 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
198 |
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(bot, chatbot, chatbot)
|
199 |
+
clean_chat.click(clear_chat, [], chatbot)
|
200 |
+
|
201 |
|
202 |
demo.launch()
|