Spaces:
Runtime error
Runtime error
Update app.py
Browse files12345673 unmodified lines111213141516171819202122232425262728293031323334353637383940414243444546474816 unmodified lines656667686970import gradio as grfrom huggingface_hub import InferenceClientdef respond(message,history: list[dict[str, str]],3 unmodified linestop_p,hf_token: gr.OAuthToken,):"""For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference"""client = InferenceClient(token=hf_token.token, model="openai/gpt-oss-20b")messages = [{"role": "system", "content": system_message}]messages.extend(history)messages.append({"role": "user", "content": message})response = ""for message in client.chat_completion(messages,max_tokens=max_tokens,stream=True,temperature=temperature,top_p=top_p,):choices = message.choicestoken = ""if len(choices) and choices[0].delta.content:token = choices[0].delta.contentresponse += tokenyield response"""For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface"""chatbot = gr.ChatInterface(respond,type="messages",16 unmodified linesgr.LoginButton()chatbot.render()if __name__ == "__main__":demo.launch()1234563 unmodified lines10111213141516171819202122232425262728293031323334353637383940414216 unmodified lines5960616263import gradio as grfrom huggingface_hub import InferenceClientdef respond(message,history: list[dict[str, str]],3 unmodified linestop_p,hf_token: gr.OAuthToken,):client = InferenceClient(token=hf_token.token,model="mradermacher/DeepHat-V1-7B-GGUF" # <-- Modelo correto)messages = [{"role": "system", "content": system_message}]messages.extend(history)messages.append({"role": "user", "content": message})response = ""for msg in client.chat_completion(messages=messages,max_tokens=max_tokens,stream=True,temperature=temperature,top_p=top_p,):choices = msg.choicestoken = ""if len(choices) and choices[0].delta and choices[0].delta.content:token = choices[0].delta.contentresponse += tokenyield responsechatbot = gr.ChatInterface(respond,type="messages",16 unmodified linesgr.LoginButton()chatbot.render()if __name__ == "__main__":demo.launch()
app.py+9-16