Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import os,json | |
| import requests | |
| from huggingface_hub import InferenceClient | |
| # Your endpoint URL | |
| HF_ENDPOINT = "https://fkm4akb80r7t3p6v.us-east4.gcp.endpoints.huggingface.cloud" | |
| HF_API_TOKEN = os.getenv('API_TKN_ALL') # Replace with your actual HF token | |
| headers = { | |
| "Authorization": f"Bearer {HF_API_TOKEN}", | |
| "Content-Type": "application/json", | |
| "Accept" : "application/json" | |
| } | |
| def generate_text(user_text): | |
| user_text = {"inputs": "User write a Gherkin scenario for user login and save it."} | |
| response = requests.post(HF_ENDPOINT, headers=headers, json=user_text) | |
| return response.json() | |
| # Gradio Interface | |
| gr.Interface( | |
| fn=generate_text, | |
| inputs=gr.Textbox(lines=4, label="Enter your task"), | |
| outputs=gr.Textbox(lines=6, label="Generated Text"), | |
| title="Text Generation via Hugging Face Inference Endpoint" | |
| ).launch() | |