Adedoyinjames commited on
Commit
1c66f55
·
verified ·
1 Parent(s): 80d5fa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -29,7 +29,7 @@ PERSONAL_INFO = {
29
 
30
  COMPANY_INFO = {
31
  "name": "YAH Tech",
32
- "type": "Venture studio / app development company focused on solving problems with futuristic solutions",
33
  "purpose": "Build and launch technology-driven ventures that generate profit and societal value",
34
  "primary_activity": "App development and creation of scalable business systems",
35
  "philosophy": "Learn, understand, create, and evaluate",
@@ -241,8 +241,8 @@ Current conversation:"""
241
  yah_bot = YAHBot()
242
 
243
  def chat_function(message, history):
244
- """Chat function for Gradio interface"""
245
- # Convert Gradio history format to our format
246
  conversation_history = []
247
  for human_msg, assistant_msg in history:
248
  conversation_history.append({"role": "user", "content": human_msg})
@@ -252,12 +252,10 @@ def chat_function(message, history):
252
  response = yah_bot.generate_response(message, conversation_history)
253
  return response
254
 
255
- def chat_interface(message, chat_history):
 
256
  bot_response = chat_function(message, chat_history)
257
-
258
- # Format the conversation
259
- chat_history.append([message, bot_response])
260
-
261
  return "", chat_history
262
 
263
  # Custom CSS for ChatGPT-like appearance
@@ -409,7 +407,8 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
409
  show_label=False,
410
  height=600,
411
  bubble_full_width=False,
412
- type="messages"
 
413
  )
414
 
415
  with gr.Row():
@@ -452,20 +451,20 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
452
 
453
  **How can I assist you today?** 🚀
454
  """
455
- return [[None, welcome_msg]]
456
 
457
  # Set initial welcome message
458
  demo.load(add_welcome_message, None, [chatbot])
459
 
460
- # Event handlers
461
  msg.submit(
462
- chat_interface,
463
  inputs=[msg, chatbot],
464
  outputs=[msg, chatbot]
465
  )
466
 
467
  send.click(
468
- chat_interface,
469
  inputs=[msg, chatbot],
470
  outputs=[msg, chatbot]
471
  )
 
29
 
30
  COMPANY_INFO = {
31
  "name": "YAH Tech",
32
+ "type": "venture studio / app development company focused on solving problems with futuristic solutions",
33
  "purpose": "Build and launch technology-driven ventures that generate profit and societal value",
34
  "primary_activity": "App development and creation of scalable business systems",
35
  "philosophy": "Learn, understand, create, and evaluate",
 
241
  yah_bot = YAHBot()
242
 
243
  def chat_function(message, history):
244
+ """Chat function for Gradio interface - FIXED VERSION"""
245
+ # Convert Gradio history format to our internal format
246
  conversation_history = []
247
  for human_msg, assistant_msg in history:
248
  conversation_history.append({"role": "user", "content": human_msg})
 
252
  response = yah_bot.generate_response(message, conversation_history)
253
  return response
254
 
255
+ def respond(message, chat_history):
256
+ """Fixed response function with proper message format"""
257
  bot_response = chat_function(message, chat_history)
258
+ chat_history.append((message, bot_response))
 
 
 
259
  return "", chat_history
260
 
261
  # Custom CSS for ChatGPT-like appearance
 
407
  show_label=False,
408
  height=600,
409
  bubble_full_width=False,
410
+ show_copy_button=True,
411
+ placeholder="Start chatting with YAH Tech AI..."
412
  )
413
 
414
  with gr.Row():
 
451
 
452
  **How can I assist you today?** 🚀
453
  """
454
+ return [(welcome_msg, None)]
455
 
456
  # Set initial welcome message
457
  demo.load(add_welcome_message, None, [chatbot])
458
 
459
+ # Event handlers - USING THE FIXED RESPOND FUNCTION
460
  msg.submit(
461
+ respond,
462
  inputs=[msg, chatbot],
463
  outputs=[msg, chatbot]
464
  )
465
 
466
  send.click(
467
+ respond,
468
  inputs=[msg, chatbot],
469
  outputs=[msg, chatbot]
470
  )