Spaces:
Runtime error

DoctorErkin's picture
Create Bot
ae1c0e2 verified
Raw History Blame Contribute Delete
636 Bytes
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_NAME = "mistralai/Mistral-7B-Instruct-v0.1"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
def chat_with_ai(input_text):
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=512)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
iface = gr.Interface(
fn=chat_with_ai,
inputs="text",
outputs="text",
title="Mistral 7B Chatbot",
description="AI chatbot based on Mistral 7B.",
)
iface.launch()