davidberenstein1957 HF staff commited on
Commit
076b4f2
·
1 Parent(s): dc26845

Optimize token limit and improve chat input interaction

Browse files

- Reduce max_tokens from 4000 to 2000 for more concise responses
- Add chat input clear functionality to reset input field
- Update submit_conversation outputs to include dataframe and chatbot

Files changed (1) hide show
  1. app/app.py +9 -1
app/app.py CHANGED
@@ -190,7 +190,7 @@ def respond(
190
  messages = format_history_as_messages(history)
191
  response = LANGUAGES_TO_CLIENT[language].chat.completions.create(
192
  messages=messages,
193
- max_tokens=4000,
194
  stream=False,
195
  seed=seed,
196
  temperature=temperature,
@@ -466,6 +466,13 @@ with gr.Blocks(css=css) as demo:
466
  ).then(update_dataframe, inputs=[dataframe, chatbot], outputs=[dataframe]).then(
467
  submit_conversation,
468
  inputs=[dataframe, conversation_id, session_id, language],
 
 
 
 
 
 
 
469
  )
470
 
471
  chatbot.like(
@@ -476,6 +483,7 @@ with gr.Blocks(css=css) as demo:
476
  ).then(
477
  submit_conversation,
478
  inputs=[dataframe, conversation_id, session_id, language],
 
479
  )
480
 
481
  chatbot.retry(
 
190
  messages = format_history_as_messages(history)
191
  response = LANGUAGES_TO_CLIENT[language].chat.completions.create(
192
  messages=messages,
193
+ max_tokens=2000,
194
  stream=False,
195
  seed=seed,
196
  temperature=temperature,
 
466
  ).then(update_dataframe, inputs=[dataframe, chatbot], outputs=[dataframe]).then(
467
  submit_conversation,
468
  inputs=[dataframe, conversation_id, session_id, language],
469
+ outputs=[dataframe, chatbot],
470
+ )
471
+
472
+ chat_input.clear(
473
+ fn=lambda: gr.Textbox(interactive=True),
474
+ inputs=[chat_input],
475
+ outputs=[chat_input], # Reset chat input
476
  )
477
 
478
  chatbot.like(
 
483
  ).then(
484
  submit_conversation,
485
  inputs=[dataframe, conversation_id, session_id, language],
486
+ outputs=[dataframe, chatbot],
487
  )
488
 
489
  chatbot.retry(