Update app.py
Browse files2 unmodified lines345667892 unmodified lines1213141515161718191920212223242526272811 unmodified lines404142373839404142434445464748495051525354555657585960616263432 unmodified lines
def respond( message, history: list[dict[str, str]], history: list[list[str]], system_message, max_tokens, temperature,2 unmodified lines): client = InferenceClient( token=hf_token.token, model="DeepHat/DeepHat-V1-7B" # <-- Modelo correto model="DeepHat/DeepHat-V1-7B" )
# Construção correta do histórico messages = [{"role": "system", "content": system_message}] messages.extend(history)
for user_msg, bot_msg in history: messages.append({"role": "user", "content": user_msg}) messages.append({"role": "assistant", "content": bot_msg})
# Adiciona a nova mensagem do usuário messages.append({"role": "user", "content": message})
response = ""11 unmodified lines token = choices[0].delta.content
response += token yield response
chatbot = gr.ChatInterface( respond, type="messages", additional_inputs=[ gr.Textbox(value="You are a friendly Chatbot.", label="System message"), gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"), gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"), gr.Slider( minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)", ), ],)
with gr.Blocks() as demo: with gr.Sidebar(): gr.LoginButton() chatbot.render()
if __name__ == "__main__": demo.launch() yield responseapp.py+10-30