Spaces:
Sleeping
Sleeping
File size: 775 Bytes
31935ef 3f78b1e 5c635d8 8864406 cf04b5e e9031f8 cf04b5e e9031f8 5c6ce6b 31935ef 3d76423 2c2ec58 3d76423 31935ef 3d76423 31935ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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()
|