8B-on-GPU-ZERO / app.py
alex-abb's picture
Update app.py
cf04b5e verified
raw
history blame
775 Bytes
import gradio as gr
import spaces
## Load model directly
# Load model directly
## Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Sao10K/L3-8B-Stheno-v3.2")
model = AutoModelForCausalLM.from_pretrained("Sao10K/L3-8B-Stheno-v3.2")
@spaces.GPU(duration=120)
# Fonction de génération de texte
def generate_text(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
response_ids = model.generate(inputs.input_ids)
response_text = tokenizer.decode(response_ids[0], skip_special_tokens=True)
return response_text
# Définir une fonction pour l'interface de chat
def chatbot(message,history):
return generate_text(message)
gr.ChatInterface(chatbot).launch()