Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
# Função para
|
4 |
-
def
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
return
|
10 |
|
11 |
-
# Interface
|
12 |
with gr.Blocks() as demo:
|
13 |
-
gr.Markdown("#
|
14 |
-
|
15 |
with gr.Row():
|
16 |
-
input_text = gr.Textbox(label="Texto de entrada"
|
17 |
-
|
18 |
with gr.Row():
|
19 |
-
temperature = gr.Slider(0, 1, value=0.7, label="
|
20 |
-
|
21 |
-
top_p = gr.Slider(0, 1, value=0.9, label="Top-p (nucleus sampling)")
|
22 |
-
top_k = gr.Slider(1, 100, value=50, step=1, label="Top-k")
|
23 |
-
|
24 |
-
with gr.Row():
|
25 |
-
output = gr.Textbox(label="Saída do Modelo")
|
26 |
-
|
27 |
with gr.Row():
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
predict,
|
32 |
-
inputs=[input_text, temperature, max_length, top_p, top_k],
|
33 |
-
outputs=output,
|
34 |
-
)
|
35 |
|
36 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Função para processar o texto com os parâmetros ajustáveis
|
4 |
+
def generate_response(input_text, temperature, top_p):
|
5 |
+
from transformers import pipeline
|
6 |
+
# Carregar o modelo da Hugging Face localmente ou via API
|
7 |
+
model = pipeline("text-generation", model="meta-llama/Llama-3.3-70B-Instruct")
|
8 |
+
result = model(input_text, max_length=512, temperature=temperature, top_p=top_p)
|
9 |
+
return result[0]['generated_text']
|
10 |
|
11 |
+
# Interface com entradas ajustáveis
|
12 |
with gr.Blocks() as demo:
|
13 |
+
gr.Markdown("# Ajuste de Parâmetros do Modelo")
|
|
|
14 |
with gr.Row():
|
15 |
+
input_text = gr.Textbox(label="Texto de entrada")
|
|
|
16 |
with gr.Row():
|
17 |
+
temperature = gr.Slider(0.1, 1.0, value=0.7, step=0.1, label="Temperatura")
|
18 |
+
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.1, label="Top-p")
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
with gr.Row():
|
20 |
+
output_text = gr.Textbox(label="Texto gerado", interactive=False)
|
21 |
+
generate_button = gr.Button("Gerar Resposta")
|
22 |
+
generate_button.click(generate_response, [input_text, temperature, top_p], output_text)
|
|
|
|
|
|
|
|
|
23 |
|
24 |
demo.launch()
|