import gradio as gr import requests import os API_URL = "https://api-inference.huggingface.co/models/tiiuae/falcon-7b-instruct" headers = { "Authorization": f"Bearer {os.getenv('HF_API_TOKEN')}" } def smart_bot(message): prompt = f""" You are a helpful assistant. Reply in the same language as the user input. User: {message} Assistant:""" payload = {"inputs": prompt} response = requests.post(API_URL, headers=headers, json=payload) if response.status_code == 200: result = response.json() reply = result[0]["generated_text"].split("Assistant:")[-1].strip() return reply else: return f"❌ Error {response.status_code}: {response.text}" with gr.Blocks() as app: gr.Markdown("

🤖 Tagalog-English AI ChatBot

") gr.Markdown("Created by Niko Sedan using Falcon 7B") user_input = gr.Textbox(label="💬 Your Message") bot_output = gr.Textbox(label="🤖 Bot's Reply") send_btn = gr.Button("Send") send_btn.click(fn=smart_bot, inputs=user_input, outputs=bot_output) app.launch()