|
import gradio as gr |
|
import requests |
|
import json |
|
|
|
|
|
api_url = "https://mucdasfrkkn33hj9.us-east-1.aws.endpoints.huggingface.cloud" |
|
|
|
|
|
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() |
|
|