artificialguybr commited on
Commit
e3d2c03
1 Parent(s): 4519318

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -60,14 +60,16 @@ def call_nvidia_api(history, max_tokens, temperature, top_p):
60
 
61
 
62
  def chatbot_submit(message, chat_history, system_message, max_tokens_val, temperature_val, top_p_val):
63
- """Updates the chatbot with the user message and generates a response."""
64
  print("Updating chatbot...")
65
 
 
66
  if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
67
  chat_history = user(message, chat_history, system_message)
68
  else:
69
  chat_history = user(message, chat_history)
70
 
 
71
  chat_history = call_nvidia_api(chat_history, max_tokens_val, temperature_val, top_p_val)
72
  return chat_history
73
 
@@ -81,7 +83,7 @@ def chatbot_submit(message, chat_history, system_message, max_tokens_val, temper
81
  """Submits the user message to the chatbot and updates the chat history."""
82
  if chat_history is None:
83
  chat_history = []
84
- chat_history = update_chatbot(message, chat_history, system_message, max_tokens_val, temperature_val, top_p_val)
85
  return chat_history
86
 
87
  with gr.Blocks() as demo:
 
60
 
61
 
62
  def chatbot_submit(message, chat_history, system_message, max_tokens_val, temperature_val, top_p_val):
63
+ """Submits the user message to the chatbot and updates the chat history."""
64
  print("Updating chatbot...")
65
 
66
+ # Atualiza o histórico do chat com a mensagem do usuário
67
  if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
68
  chat_history = user(message, chat_history, system_message)
69
  else:
70
  chat_history = user(message, chat_history)
71
 
72
+ # Chama a API da NVIDIA para gerar uma resposta
73
  chat_history = call_nvidia_api(chat_history, max_tokens_val, temperature_val, top_p_val)
74
  return chat_history
75
 
 
83
  """Submits the user message to the chatbot and updates the chat history."""
84
  if chat_history is None:
85
  chat_history = []
86
+ chat_history = chatbot_submit(message, chat_history, system_message, max_tokens_val, temperature_val, top_p_val)
87
  return chat_history
88
 
89
  with gr.Blocks() as demo: