Spaces:
Sleeping
Sleeping
File size: 965 Bytes
8172579 b37778a 8172579 04b3975 8172579 b516e8a 8172579 04b3975 1f2d1eb 8172579 04b3975 8172579 0093617 2fb6558 aef5ab5 8172579 04b3975 8172579 |
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 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
model_id = "microsoft/phi-1_5" # modelo 100% libre
# Carga del modelo sin device_map ni dtype
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
# Crear pipeline
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, return_full_text=False)
# Funci贸n para generar commit
def generar_commit(diff):
prompt = f"Escrib铆 solo el mensaje de commit para el siguiente cambio de c贸digo:\n{diff}"
output = pipe(prompt, max_new_tokens=40, do_sample=True, temperature=0.7)
return [output[0]["generated_text"]]
# Interfaz Gradio
demo = gr.Interface(
fn=generar_commit,
inputs=gr.Textbox(lines=10, label="C贸digo diff"),
outputs="text",
title="馃 Commit Generator",
description="Pega aqu铆 tus cambios (git diff) y gener谩 un mensaje de commit autom谩tico.",
)
demo.launch() |