Komal-patra commited on
Commit
b9acf04
·
verified ·
1 Parent(s): 667ab64
Files changed (1) hide show
  1. app.py +14 -21
app.py CHANGED
@@ -85,10 +85,16 @@ span.md.svelte-8tpqd2.chatbot.prose p {{
85
  margin-right: 8px;
86
  }}
87
  /* Enable scrolling for the chatbot messages */
88
- .chatbot .messages {{
89
  max-height: 500px; /* Adjust as needed */
90
  overflow-y: auto;
91
  }}
 
 
 
 
 
 
92
  """
93
 
94
  # Gradio interface setup
@@ -101,26 +107,13 @@ with gr.Blocks(css=custom_css) as demo:
101
 
102
  # Function to handle user input
103
  def user(user_message, history):
104
- return "", history + [[user_message, None]]
 
105
 
106
- # Function to handle bot response
107
- def bot(history):
108
- if len(history) == 1: # Check if it's the first interaction
109
- bot_message = "Hi there! How can I help you today?"
110
- history[-1][1] = bot_message # Add welcome message to history
111
- else:
112
- history[-1][1] = "" # Clear the last bot message
113
- previous_message = history[-1][0] # Access the previous user message
114
- bot_message = generate_text(previous_message) # Generate response based on previous message
115
- history[-1][1] = bot_message # Update the last bot message
116
- return history
117
 
118
- submit_button.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
119
- bot, chatbot, chatbot
120
- )
121
- msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
122
- bot, chatbot, chatbot
123
- )
124
- clear.click(lambda: None, None, chatbot, queue=False)
125
 
126
- demo.launch()
 
85
  margin-right: 8px;
86
  }}
87
  /* Enable scrolling for the chatbot messages */
88
+ .chatbot.messages {{
89
  max-height: 500px; /* Adjust as needed */
90
  overflow-y: auto;
91
  }}
92
+ /* Add transparency to chatbox */
93
+ .chatbot {{
94
+ background-color: rgba(255, 255, 255, 0.5); /* 50% transparent white background */
95
+ border: none;
96
+ box-shadow: none;
97
+ }}
98
  """
99
 
100
  # Gradio interface setup
 
107
 
108
  # Function to handle user input
109
  def user(user_message, history):
110
+ response = generate_text(user_message)
111
+ return [user_message, response]
112
 
113
+ # Event listener for submit button
114
+ submit_button.click(fn=user, inputs=[msg, chatbot], outputs=[chatbot, msg])
 
 
 
 
 
 
 
 
 
115
 
116
+ # Event listener for clear button
117
+ clear.click(fn=lambda: "", inputs=None, outputs=msg)
 
 
 
 
 
118
 
119
+ demo.launch()