Spaces:
Sleeping
Sleeping
File size: 750 Bytes
b624ed0 |
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 33 34 35 36 37 |
import gradio
from gradio_client import Client
from dotenv import load_dotenv
load_dotenv()
def redirect(query, collection_name):
import os
PRIVATE_SPACE_ID = os.getenv("PRIVATE_SPACE_ID")
PRIVATE_API_KEY = os.getenv("PRIVATE_API_KEY")
client = Client(PRIVATE_SPACE_ID, hf_token=PRIVATE_API_KEY)
result = client.predict(
query,
collection_name,
api_name="/predict"
)
return result
gradio_interface = gradio.Interface(
fn=redirect,
inputs=["text", "text"],
outputs="text",
examples=[
["Piso", "latest_peter"],
],
title="REST API with Gradio and Huggingface Spaces",
description="This is a REST API used for a project demo.",
article=""
)
gradio_interface.launch()
|