mathslearn commited on
Commit
f538e70
·
verified ·
1 Parent(s): aa560f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -97,15 +97,25 @@ prompt_template = PromptTemplate.from_template('''system role :{context} \
97
  assistance:
98
  ''')
99
 
 
 
 
100
  # Define Gradio Interface
101
- iface = gr.Interface(
102
- fn=lambda query: conversation.run(prompt_template.format(context=context, query=query)),
103
- inputs=gr.Textbox(),
104
- outputs=gr.Textbox(),
105
- live=True,
106
- )
 
 
 
 
 
 
107
 
108
  # Launch Gradio Interface
109
- iface.launch()
 
110
 
111
  # gr.load("models/ksh-nyp/llama-2-7b-chat-TCMKB").launch()
 
97
  assistance:
98
  ''')
99
 
100
+ import random
101
+ import time
102
+
103
  # Define Gradio Interface
104
+ with gr.Blocks() as chat:
105
+ chatbot = gr.Chatbot()
106
+ msg = gr.Textbox()
107
+ clear = gr.ClearButton([msg, chatbot])
108
+
109
+ def respond(message, chat_history):
110
+ # Use the global conversation variable here
111
+ response = conversation.run(message)
112
+ chat_history.append((message, response))
113
+ return response, chat_history
114
+
115
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
116
 
117
  # Launch Gradio Interface
118
+ if __name__ == "__main__":
119
+ chat.launch()
120
 
121
  # gr.load("models/ksh-nyp/llama-2-7b-chat-TCMKB").launch()