Roastem commited on
Commit
1f2e29e
1 Parent(s): 30ee5e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import torch
2
- from langchain_community.llms import CTransformers
3
  from langchain.chains import LLMChain
4
  from langchain import PromptTemplate
5
  import gradio as gr
@@ -51,9 +51,19 @@ def bot(query):
51
  return llm_response
52
 
53
 
54
- interface_html = gr.Interface(fn=bot, inputs="text", outputs="text", title='Sunny')
 
 
 
 
 
55
 
56
- # Add the <script> tag to interface_html
57
- interface_html.interface_html = interface_html.interface_html.replace('</head>', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2769307761697918" crossorigin="anonymous"></script></head>')
 
 
 
58
 
59
- interface_html.launch(share=False)
 
 
 
1
  import torch
2
+ from langchain.llms import CTransformers
3
  from langchain.chains import LLMChain
4
  from langchain import PromptTemplate
5
  import gradio as gr
 
51
  return llm_response
52
 
53
 
54
+ with gr.Blocks(title='Sunny', css="footer {visibility: hidden}") as main:
55
+ gr.Markdown("# Sunny Chatbot")
56
+ chatbot = gr.Chatbot([], elem_id="chatbot", height=700)
57
+ msg = gr.Textbox()
58
+ clear = gr.ClearButton([msg, chatbot])
59
+ css="footer {visibility: hidden}"
60
 
61
+ def respond(message, chat_history):
62
+ bot_message = bot(message)
63
+ chat_history.append((message, bot_message))
64
+ time.sleep(2)
65
+ return "", chat_history
66
 
67
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
68
+
69
+ main.launch(share=False)