nafisneehal commited on
Commit
469f469
·
verified ·
1 Parent(s): 4752301

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -49,8 +49,8 @@ def generate_response(user_input, chat_history):
49
  with torch.no_grad():
50
  outputs = model.generate(**inputs, max_new_tokens=100)
51
 
52
- # Decode response
53
- bot_reply = tokenizer.decode(outputs[0], skip_special_tokens=True)
54
 
55
  # Update chat history with user and bot interactions
56
  chat_history.append(("User", user_input))
@@ -63,7 +63,7 @@ def generate_response(user_input, chat_history):
63
  with gr.Blocks() as demo:
64
  gr.Markdown("# Chandler-Like Chatbot on GPU")
65
 
66
- chat_history = gr.Chatbot(label="Chat History")
67
  user_input = gr.Textbox(
68
  placeholder="Type your message here...", label="Your Message")
69
 
@@ -74,4 +74,11 @@ with gr.Blocks() as demo:
74
  submit_btn.click(generate_response, [user_input, chat_history], [
75
  chat_history, user_input])
76
 
 
 
 
 
 
 
 
77
  demo.launch(share=True) # Enables a public link
 
49
  with torch.no_grad():
50
  outputs = model.generate(**inputs, max_new_tokens=100)
51
 
52
+ # Decode response and remove the instruction part
53
+ bot_reply = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(instruction, "").strip()
54
 
55
  # Update chat history with user and bot interactions
56
  chat_history.append(("User", user_input))
 
63
  with gr.Blocks() as demo:
64
  gr.Markdown("# Chandler-Like Chatbot on GPU")
65
 
66
+ chat_history = gr.Chatbot(label="Chat History", elem_id="chatbox")
67
  user_input = gr.Textbox(
68
  placeholder="Type your message here...", label="Your Message")
69
 
 
74
  submit_btn.click(generate_response, [user_input, chat_history], [
75
  chat_history, user_input])
76
 
77
+ # Custom CSS to align chat labels on the left
78
+ demo.css = """
79
+ #chatbox .bot, #chatbox .user {
80
+ text-align: left;
81
+ }
82
+ """
83
+
84
  demo.launch(share=True) # Enables a public link