File size: 843 Bytes
ca03420 6f31c4b ca03420 6f31c4b 3d4e966 6f31c4b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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 <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> with your actual Hugging Face API token
headers = {
"Authorization": "Bearer <hf_token>",
"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()
|