Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| import os | |
| API_URL = "https://api-inference.huggingface.co/models/azkamannan2004/MindEase-CD-Part21-24" | |
| headers = { | |
| "Authorization": f"Bearer {os.getenv('HF_TOKEN')}" | |
| } | |
| def chat(message): | |
| payload = { | |
| "inputs": message, | |
| "parameters": { | |
| "max_new_tokens": 200, | |
| "temperature": 0.7 | |
| } | |
| } | |
| response = requests.post(API_URL, headers=headers, json=payload) | |
| try: | |
| result = response.json() | |
| if isinstance(result, list): | |
| return result[0]["generated_text"] | |
| else: | |
| return str(result) | |
| except: | |
| return "Error from model" | |
| demo = gr.Interface( | |
| fn=chat, | |
| inputs=gr.Textbox(lines=2, placeholder="Apna message likho..."), | |
| outputs="text", | |
| title="MindEase – Mental Health Chatbot", | |
| description="Stress & Depression Support (Fine-tuned Model)" | |
| ) | |
| demo.launch() | |