import gradio as gr import requests import json # Hugging Face API endpoint URL api_url = "https://mucdasfrkkn33hj9.us-east-1.aws.endpoints.huggingface.cloud" # Replace with your actual Hugging Face API token headers = { "Authorization": "Bearer ", "Content-Type": "application/json", } def chat_with_robot(inputs): data = { "inputs": inputs, "parameters": {"top_k": None}, } response = requests.post(api_url, data=json.dumps(data), headers=headers) return response.json()["generated_text"] iface = gr.Interface( fn=chat_with_robot, inputs=gr.inputs.TextInput(prompt="You:"), outputs=gr.outputs.Textbox(prompt="Bot:"), live=True, title="Chat with Robot", description="Type 'exit' to end the conversation.", ) iface.launch()