Israelpp/first_gradio
0
1import gradio as gr2from transformers import AutoModelForSeq2SeqLM, AutoTokenizer3 4# Load the Llama2 70B Chatbot model5model = AutoModelForSeq2SeqLM.from_pretrained("facebook/llama-2-70b-chat-hf")6tokenizer = AutoTokenizer.from_pretrained("facebook/llama-2-70b-chat-hf")7 8def chat(message, history):9 # Encode the message and history10 encoded_inputs = tokenizer(message, history, return_tensors="pt")11 12 # Generate a response13 response = model.generate(**encoded_inputs)14 15 # Decode the response16 response = tokenizer.decode(response, skip_special_tokens=True)17 18 return response19 20gr.ChatInterface(fn=chat).launch()