import gradio as gr import requests def query(data): headers = { "Content-Type": "application/json", "Authorization": "Bearer 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" } response = requests.post( "https://api-inference.huggingface.co/models/h2oai/h2ogpt-gm-oasst1-en-1024-12b", headers=headers, json={"inputs": data} ) result = response.json() return result.get("generated_text", "No response") iface = gr.Interface( fn=query, inputs=gr.inputs.Textbox(label="Input"), outputs=gr.outputs.Textbox(label="Output"), layout="vertical", title="Hugging Face Chatbot", description="Enter a message to chat with the model.", ) iface.launch(server_port=8889)