Abhlash commited on
Commit
4f3bf06
·
verified ·
1 Parent(s): f3b32a0

updated to chat interface

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -6,24 +6,24 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
6
  sys.path.append(current_dir)
7
 
8
  import gradio as gr
9
- from bot.chat import bot # Use the correct import for the bot directory
10
 
11
- def chat_interface(user_message, history):
12
- history.append((user_message, None)) # Append the user message to history
13
- response = bot(history) # Get the bot's response
14
- history[-1] = (user_message, response[-1][1]) # Update the last entry with the bot's response
15
- return "", history # Return empty string for the input box and updated history
16
 
17
- # Create the Gradio interface
18
- iface = gr.Interface(
19
- fn=chat_interface,
20
- inputs=["text", "state"],
21
- outputs=["text", "state"],
22
  title="BurnerBot",
23
  description="Chat with me about Burning Man! I can help with event dates, packing lists, principles, and more!",
24
  theme="soft",
25
  examples=["When is Burning Man this year?", "What are the 10 principles?", "Can you give me a packing list?"],
26
- )
27
-
28
- if __name__ == "__main__":
29
- iface.launch()
 
 
6
  sys.path.append(current_dir)
7
 
8
  import gradio as gr
9
+ from bot.chat import bot # Import the bot function from chat.py
10
 
11
+ def chat_interface(message, history):
12
+ history.append((message, None))
13
+ response = bot(history)
14
+ history[-1] = (message, response[-1][1])
15
+ return history
16
 
17
+ gr.ChatInterface(
18
+ chat_interface,
19
+ chatbot=gr.Chatbot(height=300),
20
+ textbox=gr.Textbox(placeholder="Ask me anything about Burning Man!", container=False),
 
21
  title="BurnerBot",
22
  description="Chat with me about Burning Man! I can help with event dates, packing lists, principles, and more!",
23
  theme="soft",
24
  examples=["When is Burning Man this year?", "What are the 10 principles?", "Can you give me a packing list?"],
25
+ cache_examples=False,
26
+ retry_btn=None,
27
+ undo_btn="Delete Previous",
28
+ clear_btn="Clear",
29
+ ).launch()