Spaces:
Sleeping
Sleeping
import gradio as gr | |
import spaces | |
## Load model directly | |
# Load model directly | |
# Load model directly | |
from transformers import AutoTokenizer, AutoModelForCausalLM | |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-72B-Instruct") | |
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-72B-Instruct") | |
# 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() | |