File size: 753 Bytes
8118795 cbc7e45 8118795 cbc7e45 f7d38d2 cbc7e45 8118795 f7d38d2 cbc7e45 8118795 c90ee98 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
# AI मॉडल लोड करें (यहां text-generation के लिए)
model = pipeline("text-generation", model="gpt2")
def respond(message, chat_history):
# AI मॉडल से रिस्पॉन्स लें
response = model(message, max_length=50)[0]["generated_text"]
chat_history.append({"role": "user", "content": message})
chat_history.append({"role": "assistant", "content": response})
return "", chat_history
with gr.Blocks() as demo:
chatbot = gr.Chatbot(type="messages")
msg = gr.Textbox(label="Type your message")
clear = gr.ClearButton([msg, chatbot])
msg.submit(respond, [msg, chatbot], [msg, chatbot])
demo.launch()
|