from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, AutoModelForCausalLM #tokenizer = AutoTokenizer.from_pretrained("bigscience/T0pp") #model = AutoModelForSeq2SeqLM.from_pretrained("bigscience/T0pp") tokenizer = AutoTokenizer.from_pretrained("ethzanalytics/ai-msgbot-gpt2-M") model = AutoModelForCausalLM.from_pretrained("ethzanalytics/ai-msgbot-gpt2-M") import gradio as gr import random def chat(message): history = gr.get_state() or [] if message.startswith("How many"): response = random.randint(1,10) elif message.startswith("How"): response = random.choice(["Great", "Good", "Okay", "Bad"]) elif message.startswith("Where"): response = random.choice(["Here", "There", "Somewhere"]) else: inputs = tokenizer.encode(message, return_tensors="pt") input_len = len(message) outputs = model.generate(inputs) response = tokenizer.decode(outputs[0])[input_len:] history.append((message, response)) gr.set_state(history) html = "