|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
|
|
chatbot_model = pipeline("text2text-generation", model="facebook/blenderbot-400M-distill") |
|
|
|
|
|
def inan_ai_chatbot(message, history): |
|
response = chatbot_model(message) |
|
return response[0]["generated_text"] |
|
|
|
|
|
with gr.Blocks(theme="compact") as demo: |
|
gr.Markdown("<h1 style='text-align: center; color: #4CAF50;'>İnan AI</h1>") |
|
gr.Markdown("<p style='text-align: center;'>Sohbet etmeye başlamak için aşağıdaki kutuya bir mesaj yazabilirsiniz.</p>") |
|
|
|
chatbot = gr.Chatbot(label="İnan AI Sohbet Ekranı") |
|
with gr.Row(): |
|
msg = gr.Textbox(label="Mesajınızı yazın:", placeholder="Bir şeyler yazın...") |
|
send_btn = gr.Button("Gönder") |
|
|
|
def update_ui(message, chat_history): |
|
|
|
chat_history = chat_history + [(message, "")] |
|
response = inan_ai_chatbot(message, chat_history) |
|
|
|
chat_history[-1] = (message, response) |
|
return chat_history, "" |
|
|
|
msg.submit(update_ui, [msg, chatbot], [chatbot, msg]) |
|
send_btn.click(update_ui, [msg, chatbot], [chatbot, msg]) |
|
|
|
|
|
demo.launch() |
|
|