TDN-M commited on
Commit
4a1f84e
·
verified ·
1 Parent(s): 71c134b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -5,9 +5,9 @@ from transformers import pipeline
5
  model_name = "TDN-M/tknv1" # Thay thế bằng tên người dùng và tên repository của bạn
6
  pipe = pipeline("text-generation", model=model_name, max_new_tokens=2048)
7
 
8
- def chatbot(input_text):
9
  # Tạo tin nhắn từ người dùng
10
- messages = [{"role": "user", "content": input_text}]
11
 
12
  # Sử dụng mô hình để tạo phản hồi
13
  response = pipe(messages)
@@ -15,13 +15,13 @@ def chatbot(input_text):
15
  # Trả về phản hồi từ mô hình
16
  return response[0]['generated_text']
17
 
18
- # Tạo ứng dụng Gradio
19
- iface = gr.Interface(
20
  fn=chatbot,
21
- inputs="text",
22
- outputs="text",
23
- title="Chatbot",
24
- description="chatbot sử dụng tiếng Việt",
25
  )
26
 
27
  # Chạy ứng dụng
 
5
  model_name = "TDN-M/tknv1" # Thay thế bằng tên người dùng và tên repository của bạn
6
  pipe = pipeline("text-generation", model=model_name, max_new_tokens=2048)
7
 
8
+ def chatbot(message, history):
9
  # Tạo tin nhắn từ người dùng
10
+ messages = [{"role": "user", "content": message}]
11
 
12
  # Sử dụng mô hình để tạo phản hồi
13
  response = pipe(messages)
 
15
  # Trả về phản hồi từ mô hình
16
  return response[0]['generated_text']
17
 
18
+ # Tạo ứng dụng Gradio với giao diện chatbot hiện đại
19
+ iface = gr.ChatInterface(
20
  fn=chatbot,
21
+ title="Chatbot sử dụng tiếng Việt",
22
+ description="Một chatbot sử dụng mô hình đã được huấn luyện bằng tiếng Việt.",
23
+ theme="default", # Chọn theme cho giao diện
24
+ css=".gradio-container {background-color: #f0f0f0;}" # Thêm CSS tùy chỉnh
25
  )
26
 
27
  # Chạy ứng dụng