AThirumoorthi commited on
Commit
8f4f66e
·
verified ·
1 Parent(s): 1b98168

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from langchain.chat_models import ChatOpenAI
3
+ !pip install groq
4
+ !pip install langchain-groq
5
+ !pip install langchain
6
+ !pip install gradio
7
+ !pip install huggingface_hub
8
+ !pip install langchain-community
9
+ from langchain.chat_models import ChatOpenAI
10
+
11
+
12
+
13
+
14
+
15
+
16
+ with gr.Blocks() as iface:
17
+
18
+ gr.Markdown("# Mr AI")
19
+ gr.Markdown("Hi there! I'm your friendly assistant. Ask me anything, and I'll do my best to help! (By Thirumoorthi.A)")
20
+
21
+ chat_history_output = gr.Chatbot(label="Chat History", height=400)
22
+
23
+
24
+ with gr.Row():
25
+ message_input = gr.Textbox(label="Your Question", placeholder="Type your question here...", lines=2)
26
+ submit_btn = gr.Button("Submit")
27
+ clear_btn = gr.Button("Clear Chat")
28
+
29
+ def respond(message, chat_history):
30
+ chat_history.append(("USER", message))
31
+ response = llm_chain.run(input=message)
32
+ chat_history.append(("Assistant", response))
33
+ return "", chat_history
34
+
35
+
36
+ def clear_chat():
37
+ return []
38
+
39
+
40
+
41
+ submit_btn.click(respond, inputs=[message_input, chat_history_output], outputs=[message_input, chat_history_output])
42
+ clear_btn.click(clear_chat, outputs=chat_history_output)
43
+
44
+
45
+ iface.launch()
46
+