Arthur2G commited on
Commit
ad77d46
·
1 Parent(s): d161ed8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py CHANGED
@@ -18,3 +18,39 @@ from azure.storage.filedatalake import DataLakeServiceClient
18
  from llama_index.indices.vector_store.base import GPTVectorStoreIndex
19
  from adlfs import AzureBlobFileSystem
20
  import time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  from llama_index.indices.vector_store.base import GPTVectorStoreIndex
19
  from adlfs import AzureBlobFileSystem
20
  import time
21
+
22
+ def ask_ai(doc,message):
23
+ return message
24
+
25
+ header = """<center><b><p style=\"color: #E13C32; font-size: 36px;\">My Ardian Chatbot</p></b></center>
26
+ <i><p style=\"font-size: 16px; color: grey;\">Please make sure to formulate clear and precise questions and to add contextual information when possible. This will help the tool produce the most relevant response. Adopt an iterative approach and ask for more details or explanations when necessary.</br><i/></p>"""
27
+
28
+ footnote = "<p style=\"font-size: 16px; color: grey;\"> ⚠ The chatbot doesn't have a memory, it doesn't remember what it previously generated.</a></p>"
29
+
30
+ theme = gr.themes.Base(
31
+ primary_hue="red",
32
+ secondary_hue="gray",
33
+ font=['FuturaTOT', '=', '36px']
34
+ )
35
+
36
+
37
+ with gr.Blocks(theme=theme) as demo:
38
+ gr.Markdown(header)
39
+
40
+ download_button = gr.inputs.File(label="Upload a PDF")
41
+ chatbot = gr.Chatbot()
42
+ question = gr.Textbox(label='Question', info="Please write your question here.")
43
+ clear = gr.Button("Clear")
44
+
45
+ def respond(message, chat_history, doc):
46
+ bot_message = ask_ai(doc, message)
47
+ chat_history.append((message, bot_message))
48
+ time.sleep(2)
49
+ return "", chat_history
50
+
51
+ question.submit(respond, [question, chatbot, download_button], [question, chatbot])
52
+
53
+ clear.click(lambda: None, None, chatbot, queue=False)
54
+ gr.Markdown(footnote)
55
+
56
+ demo.launch(share=True, auth=("username", "password"), debug=True)