Spaces:
Sleeping
Sleeping
File size: 1,159 Bytes
1a118a7 a203b87 b9595bd 6fde106 e2c6d83 a203b87 f0ff02a a203b87 e261970 67ed24a 193f2dc f0ff02a 193f2dc b9595bd 193f2dc 5498e60 b9595bd a203b87 e2c6d83 193f2dc a203b87 e2c6d83 b9595bd f0ff02a e2c6d83 36d0fab f0ff02a e2c6d83 f0ff02a b9595bd e2c6d83 1a118a7 5f4e717 | 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 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("<h1 style='text-align: center;'>🤖 Tagalog-English AI ChatBot</h1>")
gr.Markdown("<marquee style='color: black; font-weight: bold;'>Created by Niko Sedan using Falcon 7B</marquee>")
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()
|