Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Thay mô hình nếu bạn biết rõ hơn mô hình cũ | |
| reply_pipeline = pipeline("text-generation", model="microsoft/DialoGPT-medium") | |
| def reply_comment(comment): | |
| prompt = f"Trả lời một cách thân thiện, tự nhiên, có thể hài hước:\nBình luận: {comment}\nTrả lời:" | |
| response = reply_pipeline(prompt, max_length=100, do_sample=True) | |
| return response[0]['generated_text'].replace(prompt, "").strip() | |
| gr.Interface( | |
| fn=reply_comment, | |
| inputs=gr.Textbox(label="Nhập bình luận cần trả lời", placeholder="Ví dụ: Sản phẩm này có tốt không vậy?"), | |
| outputs=gr.Textbox(label="Phản hồi AI"), | |
| title="Comment Reply AI 🐠", | |
| description="Nhập một bình luận, AI sẽ đề xuất câu trả lời phù hợp" | |
| ).launch() | |