File size: 442 Bytes
17b686a
b18e82e
17b686a
7dc6911
17b686a
c5b594f
 
43705db
 
 
6b792a7
43705db
7dc6911
c5b594f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
from transformers import pipeline

generator = pipeline("text-generation", model="distilgpt2")

def chat_fn(message, history=None):
    try:
        response = generator(message, max_length=100, pad_token_id=50256)
        bot_reply = response[0]['generated_text'].strip()
        return bot_reply, history or []
    except Exception as e:
        return f"Error: {e}", history or []

gr.ChatInterface(fn=chat_fn).launch()