itnbkcs / app.py
ngoccs's picture
Update app.py
3b5d739 verified
Raw History Blame Contribute Delete
613 Bytes
import gradio as gr
import os
from google import genai
# Lấy API key từ HuggingFace Secrets
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"))
def chat_with_ai(message):
if not message.strip():
return "⚠️ Bạn chưa nhập nội dung."
response = client.models.generate_content(
model="gemini-1.5-flash",
contents=message
)
return response.text
interface = gr.Interface(
fn=chat_with_ai,
inputs="text",
outputs="text",
title="Trợ lý học lập trình",
description="AI hỗ trợ học sinh luyện tập"
)
interface.launch()