artificialguybr commited on
Commit
be13696
1 Parent(s): c15a43b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -72,7 +72,13 @@ def update_chatbot(message, chat_history, system_message, max_tokens, temperatur
72
  chat_history = user(message, chat_history)
73
  chat_history, _ = call_nvidia_api(chat_history, max_tokens, temperature, top_p)
74
  return chat_history
75
-
 
 
 
 
 
 
76
  # Gradio interface setup
77
  with gr.Blocks() as demo:
78
  with gr.Row():
@@ -96,23 +102,16 @@ with gr.Blocks() as demo:
96
  """
97
  gr.Markdown(description)
98
  chatbox = gr.Textbox(label="What do you want to chat about?", placeholder="Ask me anything.", lines=3)
99
- system_msg = gr.Textbox(BASE_SYSTEM_MESSAGE, label="System Message", placeholder="System prompt.", lines=5)
100
- max_tokens = gr.Slider(20, 1024, label="Max Tokens", step=20, value=1024, interactive=True)
101
- temperature = gr.Slider(0.0, 1.0, label="Temperature", step=0.1, value=0.2, interactive=True)
102
- top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.7, interactive=True)
103
  chat_history_state = gr.State([])
104
 
105
- additional_inputs = [system_msg, max_tokens, temperature, top_p]
106
-
107
  chatbot = gr.ChatInterface(
108
- fn=update_chatbot,
109
- inputs=[chatbox, chat_history_state],
110
- outputs=chat_history_state,
111
- additional_inputs=additional_inputs,
112
  title="LLAMA 2 70B Chatbot",
113
  submit_btn="Submit",
114
  clear_btn="🗑️ Clear",
115
- textbox=chatbox,
116
  )
117
 
118
  chatbot.clear(
 
72
  chat_history = user(message, chat_history)
73
  chat_history, _ = call_nvidia_api(chat_history, max_tokens, temperature, top_p)
74
  return chat_history
75
+
76
+ system_msg = gr.Textbox(BASE_SYSTEM_MESSAGE, label="System Message", placeholder="System prompt.", lines=5)
77
+ max_tokens = gr.Slider(20, 1024, label="Max Tokens", step=20, value=1024)
78
+ temperature = gr.Slider(0.0, 1.0, label="Temperature", step=0.1, value=0.2)
79
+ top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.7)
80
+
81
+
82
  # Gradio interface setup
83
  with gr.Blocks() as demo:
84
  with gr.Row():
 
102
  """
103
  gr.Markdown(description)
104
  chatbox = gr.Textbox(label="What do you want to chat about?", placeholder="Ask me anything.", lines=3)
 
 
 
 
105
  chat_history_state = gr.State([])
106
 
 
 
107
  chatbot = gr.ChatInterface(
108
+ fn=lambda message, history: update_chatbot(message, history, system_msg.value, max_tokens.value, temperature.value, top_p.value),
109
+ chatbot=None, # Use o componente padrão do Chatbot
110
+ textbox=chatbox, # Personalize o componente Textbox se necessário
111
+ additional_inputs=[system_msg, max_tokens, temperature, top_p], # Componentes adicionais
112
  title="LLAMA 2 70B Chatbot",
113
  submit_btn="Submit",
114
  clear_btn="🗑️ Clear",
 
115
  )
116
 
117
  chatbot.clear(