import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer # Carrega o modelo e o tokenizer model_name = "ytu-ce-cosmos/Turkish-Llama-8b-DPO-v0.1" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name) def generate_text(prompt): inputs = tokenizer(prompt, return_tensors="pt") outputs = model.generate(**inputs) return tokenizer.decode(outputs[0], skip_special_tokens=True) # Cria a interface Gradio interface = gr.Interface(fn=generate_text, inputs="text", outputs="text") interface.launch()