nalayoarias commited on
Commit
051c33f
·
1 Parent(s): 35de55a

Refactor Gradio interface layout and update slider parameters for improved user experience

Browse files
Files changed (1) hide show
  1. app_gradio.py +44 -73
app_gradio.py CHANGED
@@ -25,86 +25,57 @@ def process_text(api_key, current_text, max_tokens, temperature):
25
  with gr.Blocks(title="GPT Text Continuation", theme=gr.themes.Soft()) as demo:
26
  gr.Markdown(
27
  """
28
- # 🚀 GPT Text Continuation
29
- ### Continúa cualquier texto usando la API de OpenAI
30
-
31
- **Instrucciones:**
32
- 1. Introduce tu API Key de OpenAI
33
- 2. Escribe el texto que quieres continuar
34
- 3. Ajusta los parámetros si es necesario
35
- 4. Haz clic en "Continuar Texto"
36
  """
37
  )
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  with gr.Row():
40
- with gr.Column(scale=2):
41
- # Campo para la API Key
42
- api_key_input = gr.Textbox(
43
- label="🔑 OpenAI API Key",
44
- placeholder="sk-...",
45
- type="password",
46
- info="Tu API Key se mantiene privada y no se almacena"
47
- )
48
-
49
- # Área de texto principal
50
- text_area = gr.Textbox(
51
- label="📝 Texto",
52
- placeholder="Escribe aquí el texto que quieres continuar...",
53
- lines=8,
54
- max_lines=15,
55
- info="El texto continuado aparecerá aquí mismo"
56
- )
57
-
58
- # Botón principal
59
- continue_btn = gr.Button(
60
- "✨ Continuar Texto",
61
- variant="primary",
62
- size="lg"
63
- )
64
-
65
- with gr.Column(scale=1):
66
- gr.Markdown("### ⚙️ Configuración")
67
-
68
- max_tokens_slider = gr.Slider(
69
- minimum=50,
70
- maximum=500,
71
- value=150,
72
- step=25,
73
- label="Máximo de tokens",
74
- info="Longitud máxima de la continuación"
75
- )
76
-
77
- temperature_slider = gr.Slider(
78
- minimum=0.1,
79
- maximum=1.0,
80
- value=0.7,
81
- step=0.1,
82
- label="Creatividad (Temperature)",
83
- info="0.1 = más conservador, 1.0 = más creativo"
84
- )
85
-
86
- gr.Markdown(
87
- """
88
- ### 💡 Consejos
89
- - **Tokens**: Controla la longitud de la respuesta
90
- - **Creatividad**: Valores bajos = más predecible, valores altos = más creativo
91
- - **API Key**: Puedes obtener una en [OpenAI](https://platform.openai.com/api-keys)
92
- """
93
- )
94
 
95
- # Ejemplos
96
- gr.Markdown("### 📚 Ejemplos para probar:")
97
- example_texts = [
98
- "Era una noche oscura y tormentosa cuando",
99
- "La inteligencia artificial está transformando",
100
- "En un futuro no muy lejano, los robots",
101
- "El secreto mejor guardado de la humanidad"
102
- ]
103
 
 
104
  gr.Examples(
105
- examples=example_texts,
106
- inputs=text_area,
107
- label="Haz clic en cualquier ejemplo para probarlo"
 
 
 
108
  )
109
 
110
  # Conectar el botón con la función
 
25
  with gr.Blocks(title="GPT Text Continuation", theme=gr.themes.Soft()) as demo:
26
  gr.Markdown(
27
  """
28
+ # GPT Text Continuation
29
+ Continúa cualquier texto usando la API de OpenAI
 
 
 
 
 
 
30
  """
31
  )
32
 
33
+ # Campo para la API Key
34
+ api_key_input = gr.Textbox(
35
+ label="🔑 OpenAI API Key",
36
+ placeholder="sk-...",
37
+ type="password"
38
+ )
39
+
40
+ # Área de texto principal
41
+ text_area = gr.Textbox(
42
+ label="📝 Texto",
43
+ placeholder="Escribe aquí el texto que quieres continuar...",
44
+ lines=6
45
+ )
46
+
47
  with gr.Row():
48
+ max_tokens_slider = gr.Slider(
49
+ minimum=1,
50
+ maximum=100,
51
+ value=50,
52
+ step=5,
53
+ label="Tokens máximos"
54
+ )
55
+
56
+ temperature_slider = gr.Slider(
57
+ minimum=0.1,
58
+ maximum=1.0,
59
+ value=0.7,
60
+ step=0.1,
61
+ label="Creatividad"
62
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
+ # Botón principal
65
+ continue_btn = gr.Button(
66
+ "✨ Continuar Texto",
67
+ variant="primary",
68
+ size="lg"
69
+ )
 
 
70
 
71
+ # Ejemplos
72
  gr.Examples(
73
+ examples=[
74
+ "Era una noche oscura y tormentosa cuando",
75
+ "La inteligencia artificial está transformando",
76
+ "En un futuro no muy lejano, los robots"
77
+ ],
78
+ inputs=text_area
79
  )
80
 
81
  # Conectar el botón con la función