artificialguybr commited on
Commit
c2cf64d
·
verified ·
1 Parent(s): 8cf9380

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -59,7 +59,7 @@ def call_nvidia_api(history, max_tokens, temperature, top_p):
59
 
60
  return history
61
 
62
- def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
63
  print("Starting chat...")
64
  updated_history = call_nvidia_api(history, max_tokens, temperature, top_p)
65
  return updated_history, ""
@@ -100,13 +100,13 @@ with gr.Blocks() as demo:
100
  chat_history_state = gr.State([])
101
 
102
  # Ajuste na definição da função update_chatbot para aceitar o valor atualizado do system_msg
103
- def update_chatbot(message, chat_history, system_message): # Remova o valor padrão aqui
104
  print("Updating chatbot...")
105
  if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
106
  chat_history = user(message, chat_history, system_message if not chat_history else None)
107
  else:
108
  chat_history = user(message, chat_history)
109
- chat_history, _ = chat(chat_history, system_message, max_tokens.value, temperature.value, top_p.value, 40, 1.1)
110
 
111
  formatted_chat_history = []
112
  for user_msg, assistant_msg in zip([msg["content"].strip() for msg in chat_history if msg["role"] == "user"],
@@ -116,10 +116,9 @@ with gr.Blocks() as demo:
116
 
117
  return formatted_chat_history, chat_history, ""
118
 
119
- # Ajuste na chamada do botão submit para incluir system_msg como um input
120
  submit.click(
121
  fn=update_chatbot,
122
- inputs=[message, chat_history_state, system_msg], # Inclua system_msg aqui
123
  outputs=[chatbot, chat_history_state, message]
124
  )
125
 
 
59
 
60
  return history
61
 
62
+ def chat(history, system_message, max_tokens, temperature, top_p):
63
  print("Starting chat...")
64
  updated_history = call_nvidia_api(history, max_tokens, temperature, top_p)
65
  return updated_history, ""
 
100
  chat_history_state = gr.State([])
101
 
102
  # Ajuste na definição da função update_chatbot para aceitar o valor atualizado do system_msg
103
+ def update_chatbot(message, chat_history, system_message, max_tokens, temperature, top_p):
104
  print("Updating chatbot...")
105
  if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
106
  chat_history = user(message, chat_history, system_message if not chat_history else None)
107
  else:
108
  chat_history = user(message, chat_history)
109
+ chat_history, _ = chat(chat_history, system_message, max_tokens, temperature, top_p)
110
 
111
  formatted_chat_history = []
112
  for user_msg, assistant_msg in zip([msg["content"].strip() for msg in chat_history if msg["role"] == "user"],
 
116
 
117
  return formatted_chat_history, chat_history, ""
118
 
 
119
  submit.click(
120
  fn=update_chatbot,
121
+ inputs=[message, chat_history_state, system_msg, max_tokens, temperature, top_p],
122
  outputs=[chatbot, chat_history_state, message]
123
  )
124