DHEIVER commited on
Commit
bb97b78
·
verified ·
1 Parent(s): e07965d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -75,7 +75,7 @@ def create_chat_app():
75
  temperature: float,
76
  top_p: float,
77
  language: str,
78
- ) -> str:
79
  try:
80
  client = Client("aifeifei798/feifei-chat")
81
 
@@ -99,10 +99,13 @@ def create_chat_app():
99
  api_name="/chat"
100
  )
101
 
102
- return response
 
103
 
104
  except Exception as e:
105
- return TRANSLATIONS[language]["error_message"].format(str(e))
 
 
106
 
107
  def update_interface(language: str):
108
  trans = TRANSLATIONS[language]
@@ -133,7 +136,7 @@ def create_chat_app():
133
  with gr.Group():
134
  chatbot = gr.Chatbot(
135
  value=[],
136
- type="messages", # Using the new messages format
137
  label=TRANSLATIONS["en"]["title"]
138
  )
139
  msg = gr.Textbox(
@@ -174,9 +177,8 @@ def create_chat_app():
174
  # Set up chat functionality
175
  msg.submit(
176
  respond,
177
- [msg, chatbot, system_msg, max_tokens, temperature, top_p, language],
178
- [chatbot],
179
- clear_input=True
180
  )
181
 
182
  # Examples
 
75
  temperature: float,
76
  top_p: float,
77
  language: str,
78
+ ) -> Tuple[List[Tuple[str, str]], str]:
79
  try:
80
  client = Client("aifeifei798/feifei-chat")
81
 
 
99
  api_name="/chat"
100
  )
101
 
102
+ chat_history.append((message, response))
103
+ return chat_history, "" # Return updated history and empty message
104
 
105
  except Exception as e:
106
+ error_msg = TRANSLATIONS[language]["error_message"].format(str(e))
107
+ chat_history.append((message, error_msg))
108
+ return chat_history, ""
109
 
110
  def update_interface(language: str):
111
  trans = TRANSLATIONS[language]
 
136
  with gr.Group():
137
  chatbot = gr.Chatbot(
138
  value=[],
139
+ height=400,
140
  label=TRANSLATIONS["en"]["title"]
141
  )
142
  msg = gr.Textbox(
 
177
  # Set up chat functionality
178
  msg.submit(
179
  respond,
180
+ inputs=[msg, chatbot, system_msg, max_tokens, temperature, top_p, language],
181
+ outputs=[chatbot, msg] # Update chat history and clear message input
 
182
  )
183
 
184
  # Examples