Ahmed-El-Sharkawy commited on
Commit
bbe3c6c
·
verified ·
1 Parent(s): f8d93b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -20
app.py CHANGED
@@ -132,30 +132,42 @@ def respond(user_message: str, state: dict):
132
  state["messages"].append({"role": "assistant", "content": reply})
133
  return reply, state
134
 
135
- # ------------------- Gradio UI: messages API (Gradio >= 5) -------------------
136
  with gr.Blocks(title="Ghaymah Chatbot") as demo:
137
- gr.Markdown("# 🤖 Ghaymah Chatbot ")
138
- gr.Markdown(
139
- "Vector store: **Connected** \n"
140
- f"Embedder: `{Embed_Model_Name or 'unset'}` \n"
141
- f"RPM limit: **{RPM_LIMIT}** (min {MIN_SECONDS_BETWEEN}s between calls) \n"
142
- )
143
-
144
  state = gr.State(init_state()) # {"messages": [...], "last_call_ts": ...}
145
 
146
- # Start with an explicit empty list so it's never None
147
- chatbot = gr.Chatbot(label="Chat", height=520, type="messages", value=[])
148
-
149
- with gr.Row():
150
- txt = gr.Textbox(
151
- placeholder="Ask anything about the Ghaymah documentation…",
152
- label="Your message",
153
- lines=2,
154
- autofocus=True,
155
- )
156
  with gr.Row():
157
- send_btn = gr.Button("Send", variant="primary")
158
- clear_btn = gr.Button("Clear")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
  # Step 1: add a user message immediately
161
  def _on_user_submit(user_input, chat_messages):
@@ -218,3 +230,5 @@ with gr.Blocks(title="Ghaymah Chatbot") as demo:
218
  if __name__ == "__main__":
219
  demo.queue()
220
  demo.launch(debug=True)
 
 
 
132
  state["messages"].append({"role": "assistant", "content": reply})
133
  return reply, state
134
 
135
+ # Gradio UI: messages API (Gradio >= 5)
136
  with gr.Blocks(title="Ghaymah Chatbot") as demo:
 
 
 
 
 
 
 
137
  state = gr.State(init_state()) # {"messages": [...], "last_call_ts": ...}
138
 
 
 
 
 
 
 
 
 
 
 
139
  with gr.Row():
140
+ # LEFT: chat + input
141
+ with gr.Column(scale=3):
142
+ gr.Markdown("# 🤖 Ghaymah Chatbot")
143
+
144
+ # Start with an explicit empty list so it's never None
145
+ chatbot = gr.Chatbot(label="Chat", height=520, type="messages", value=[])
146
+
147
+ # Input + buttons under the chat
148
+ txt = gr.Textbox(
149
+ placeholder="Ask anything about the Ghaymah documentation…",
150
+ label="Your message",
151
+ lines=2,
152
+ autofocus=True,
153
+ )
154
+ with gr.Row():
155
+ send_btn = gr.Button("Send", variant="primary")
156
+ clear_btn = gr.Button("Clear")
157
+
158
+ # RIGHT: logo + status text (from the first screenshot), stacked vertically
159
+ with gr.Column(scale=1, min_width=300):
160
+ gr.Image(
161
+ value="download.jpeg", # logo on the right
162
+ show_label=False,
163
+ height=260,
164
+ interactive=False,
165
+ )
166
+ gr.Markdown(
167
+ "Vector store: **Connected** \n"
168
+ f"Embedder: `{Embed_Model_Name or 'unset'}` \n"
169
+ f"RPM limit: **{RPM_LIMIT}** (min {MIN_SECONDS_BETWEEN}s between calls) \n"
170
+ )
171
 
172
  # Step 1: add a user message immediately
173
  def _on_user_submit(user_input, chat_messages):
 
230
  if __name__ == "__main__":
231
  demo.queue()
232
  demo.launch(debug=True)
233
+ demo.launch(share=True)
234
+ demo.launch(ssr_mode=False)