Thziin's picture
Update app.py
6fcde8c verified
raw
history blame
1.07 kB
import gradio as gr
# Função para processar o texto com os parâmetros ajustáveis
def generate_response(input_text, temperature, top_p):
from transformers import pipeline
# Carregar o modelo da Hugging Face localmente ou via API
model = pipeline("text-generation", model="EmTpro01/CodeLlama-7b-finetuned-16bit")
result = model(input_text, max_length=512, temperature=temperature, top_p=top_p)
return result[0]['generated_text']
# Interface com entradas ajustáveis
with gr.Blocks() as demo:
gr.Markdown("# Ajuste de Parâmetros do Modelo")
with gr.Row():
input_text = gr.Textbox(label="Texto de entrada")
with gr.Row():
temperature = gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperatura")
top_p = gr.Slider(0.1, 2.0, value=0.9, step=0.1, label="Top-p")
with gr.Row():
output_text = gr.Textbox(label="Texto gerado", interactive=False)
generate_button = gr.Button("Gerar Resposta")
generate_button.click(generate_response, [input_text, temperature, top_p], output_text)
demo.launch()