Update app.py
Browse files12345676 unmodified lines141516171819202122232425262728295 unmodified lines353637383940414243444518 unmodified lines646566676869import gradio as grfrom huggingface_hub import InferenceClientdef respond(message,history: list[dict[str, str]],6 unmodified lines"""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="ibm-granite/granite-4.0-h-small")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,5 unmodified linestoken = ""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"""18 unmodified linesgr.LoginButton()chatbot.render()if __name__ == "__main__":demo.launch()1234567896 unmodified lines16171819202122232425262728295 unmodified lines35363738394041424318 unmodified lines6263646566import gradio as grimport spacesfrom huggingface_hub import InferenceClient# The decorator MUST go right here, before the 'def'@spaces.GPUdef respond(message,history: list[dict[str, str]],6 unmodified lines"""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,5 unmodified linestoken = ""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"""18 unmodified linesgr.LoginButton()chatbot.render()if __name__ == "__main__":demo.launch()
app.py+8-11