jchen8000 commited on
Commit
908889a
·
verified ·
1 Parent(s): 6a23be3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from langchain.chains import ConversationChain
3
+ from langchain.memory import ConversationBufferMemory
4
+ from langchain.llms import Groq
5
+
6
+ # Initialize the language model and memory
7
+ llm = Groq(api_key="your_groq_api_key")
8
+ memory = ConversationBufferMemory()
9
+
10
+ # Define the conversation chain
11
+ conversation = ConversationChain(llm=llm, memory=memory)
12
+
13
+ # Function to generate responses
14
+ def generate_response(user_input):
15
+ response = conversation.run(user_input)
16
+ return response
17
+
18
+ # Define additional inputs and examples if needed
19
+ additional_inputs = []
20
+ example1 = []
21
+
22
+ # Create the Gradio interface
23
+ interface = gr.ChatInterface(
24
+ fn=generate_response,
25
+ theme="Nymbo/Alyx_Theme",
26
+ chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
27
+ additional_inputs=additional_inputs,
28
+ examples=example1,
29
+ cache_examples=False,
30
+ )
31
+
32
+ # Launch the app
33
+ interface.launch()