Spaces:
Running
Running
Update interface.py
Browse files- interface.py +117 -35
interface.py
CHANGED
@@ -12,74 +12,148 @@ css_customizado = """
|
|
12 |
max-width: 1400px !important;
|
13 |
margin: 0 auto;
|
14 |
width: 99%;
|
15 |
-
height: 100vh !important;
|
16 |
display: flex;
|
17 |
flex-direction: column;
|
|
|
18 |
}
|
|
|
19 |
.main-content {
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
display: flex;
|
23 |
flex-direction: column;
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
.gr-textbox textarea {
|
27 |
font-size: 14px !important;
|
28 |
line-height: 1.5 !important;
|
29 |
}
|
|
|
30 |
.resposta-container {
|
31 |
background-color: #ffffff !important;
|
32 |
color: #1a1a1a !important;
|
33 |
border: 1px solid #e0e0e0 !important;
|
34 |
border-radius: 20px !important;
|
35 |
padding: 20px !important;
|
36 |
-
margin:
|
37 |
-
height: 10vh !important;
|
38 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
|
39 |
}
|
|
|
40 |
.resposta-container pre code {
|
41 |
color: #1a1a1a !important;
|
42 |
background-color: #f8f9fa !important;
|
43 |
}
|
|
|
44 |
.pergunta-container {
|
45 |
background-color: #f0f8ff !important;
|
46 |
border-radius: 8px !important;
|
47 |
padding: 15px !important;
|
48 |
}
|
49 |
-
|
50 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
51 |
-
color: white !important;
|
52 |
-
padding: 20px !important; /* Ajustado para padding consistente */
|
53 |
-
border-radius: 10px !important;
|
54 |
-
margin-bottom: 10px !important;
|
55 |
-
text-align: center !important;
|
56 |
-
}
|
57 |
.modelo-dropdown {
|
58 |
margin-bottom: 15px !important;
|
59 |
}
|
|
|
60 |
.unequal-height.svelte-1xp0cw7 {
|
61 |
align-items: normal !important;
|
62 |
}
|
|
|
63 |
div.svelte-1xp0cw7 {
|
64 |
display: grid !important;
|
65 |
}
|
|
|
66 |
#entrada_usuario textarea {
|
67 |
color: white !important;
|
68 |
font-size: large !important;
|
69 |
background-color: #1a1a1a !important;
|
|
|
70 |
}
|
|
|
71 |
.message-content {
|
72 |
font-size: larger;
|
73 |
color: white !important;
|
74 |
background-color: #1a1a1a !important;
|
75 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
"""
|
77 |
|
78 |
def criar_interface():
|
79 |
with gr.Blocks(title="Dr. Aldo Henrique - API Externa", theme=gr.themes.Soft(), css=css_customizado) as interface:
|
80 |
-
# Contêiner principal para o conteúdo visível
|
81 |
with gr.Column(elem_classes="main-content"):
|
82 |
-
# Cabeçalho
|
83 |
gr.HTML("""
|
84 |
<div class="titulo-principal">
|
85 |
<h4>🤖 iAldo - Pergunte e aprenda</h4>
|
@@ -87,28 +161,36 @@ def criar_interface():
|
|
87 |
</div>
|
88 |
""")
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
label="🧠 Selecione o Modelo de IA",
|
97 |
-
info="Escolha o modelo para responder",
|
98 |
-
elem_classes="modelo-dropdown"
|
99 |
)
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
-
#
|
111 |
-
with gr.Column():
|
112 |
# RAG
|
113 |
with gr.Accordion("⚙️ Controle do Conhecimento (RAG)", open=False):
|
114 |
status_rag = gr.Textbox(label="Status do Retreino", interactive=False)
|
|
|
12 |
max-width: 1400px !important;
|
13 |
margin: 0 auto;
|
14 |
width: 99%;
|
15 |
+
height: 100vh !important;
|
16 |
display: flex;
|
17 |
flex-direction: column;
|
18 |
+
overflow: hidden;
|
19 |
}
|
20 |
+
|
21 |
.main-content {
|
22 |
+
height: 100vh !important;
|
23 |
+
display: flex;
|
24 |
+
flex-direction: column;
|
25 |
+
overflow: hidden;
|
26 |
+
}
|
27 |
+
|
28 |
+
.titulo-principal {
|
29 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
30 |
+
color: white !important;
|
31 |
+
padding: 20px !important;
|
32 |
+
border-radius: 10px !important;
|
33 |
+
margin-bottom: 10px !important;
|
34 |
+
text-align: center !important;
|
35 |
+
height: 10vh !important;
|
36 |
display: flex;
|
37 |
flex-direction: column;
|
38 |
+
justify-content: center;
|
39 |
+
align-items: center;
|
40 |
+
flex-shrink: 0;
|
41 |
+
}
|
42 |
+
|
43 |
+
.chat-container {
|
44 |
+
height: 70vh !important;
|
45 |
+
overflow-y: auto;
|
46 |
+
flex-shrink: 0;
|
47 |
+
margin-bottom: 10px;
|
48 |
}
|
49 |
+
|
50 |
+
.input-container {
|
51 |
+
height: 20vh !important;
|
52 |
+
display: flex;
|
53 |
+
flex-direction: column;
|
54 |
+
justify-content: center;
|
55 |
+
flex-shrink: 0;
|
56 |
+
padding: 10px 0;
|
57 |
+
}
|
58 |
+
|
59 |
+
.additional-content {
|
60 |
+
overflow-y: auto;
|
61 |
+
padding-top: 20px;
|
62 |
+
}
|
63 |
+
|
64 |
.gr-textbox textarea {
|
65 |
font-size: 14px !important;
|
66 |
line-height: 1.5 !important;
|
67 |
}
|
68 |
+
|
69 |
.resposta-container {
|
70 |
background-color: #ffffff !important;
|
71 |
color: #1a1a1a !important;
|
72 |
border: 1px solid #e0e0e0 !important;
|
73 |
border-radius: 20px !important;
|
74 |
padding: 20px !important;
|
75 |
+
margin: 10px 0 !important;
|
|
|
76 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
|
77 |
}
|
78 |
+
|
79 |
.resposta-container pre code {
|
80 |
color: #1a1a1a !important;
|
81 |
background-color: #f8f9fa !important;
|
82 |
}
|
83 |
+
|
84 |
.pergunta-container {
|
85 |
background-color: #f0f8ff !important;
|
86 |
border-radius: 8px !important;
|
87 |
padding: 15px !important;
|
88 |
}
|
89 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
.modelo-dropdown {
|
91 |
margin-bottom: 15px !important;
|
92 |
}
|
93 |
+
|
94 |
.unequal-height.svelte-1xp0cw7 {
|
95 |
align-items: normal !important;
|
96 |
}
|
97 |
+
|
98 |
div.svelte-1xp0cw7 {
|
99 |
display: grid !important;
|
100 |
}
|
101 |
+
|
102 |
#entrada_usuario textarea {
|
103 |
color: white !important;
|
104 |
font-size: large !important;
|
105 |
background-color: #1a1a1a !important;
|
106 |
+
min-height: 60px !important;
|
107 |
}
|
108 |
+
|
109 |
.message-content {
|
110 |
font-size: larger;
|
111 |
color: white !important;
|
112 |
background-color: #1a1a1a !important;
|
113 |
}
|
114 |
+
|
115 |
+
/* Responsivo para dispositivos móveis */
|
116 |
+
@media (max-width: 768px) {
|
117 |
+
.titulo-principal {
|
118 |
+
height: 12vh !important;
|
119 |
+
padding: 15px !important;
|
120 |
+
}
|
121 |
+
|
122 |
+
.chat-container {
|
123 |
+
height: 68vh !important;
|
124 |
+
}
|
125 |
+
|
126 |
+
.input-container {
|
127 |
+
height: 20vh !important;
|
128 |
+
}
|
129 |
+
|
130 |
+
#entrada_usuario textarea {
|
131 |
+
min-height: 50px !important;
|
132 |
+
font-size: 16px !important;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
@media (max-width: 480px) {
|
137 |
+
.titulo-principal {
|
138 |
+
height: 15vh !important;
|
139 |
+
padding: 10px !important;
|
140 |
+
}
|
141 |
+
|
142 |
+
.chat-container {
|
143 |
+
height: 65vh !important;
|
144 |
+
}
|
145 |
+
|
146 |
+
.input-container {
|
147 |
+
height: 20vh !important;
|
148 |
+
}
|
149 |
+
}
|
150 |
"""
|
151 |
|
152 |
def criar_interface():
|
153 |
with gr.Blocks(title="Dr. Aldo Henrique - API Externa", theme=gr.themes.Soft(), css=css_customizado) as interface:
|
154 |
+
# Contêiner principal para o conteúdo visível (100vh)
|
155 |
with gr.Column(elem_classes="main-content"):
|
156 |
+
# Cabeçalho - 10% da tela
|
157 |
gr.HTML("""
|
158 |
<div class="titulo-principal">
|
159 |
<h4>🤖 iAldo - Pergunte e aprenda</h4>
|
|
|
161 |
</div>
|
162 |
""")
|
163 |
|
164 |
+
# Área do chat - 70% da tela
|
165 |
+
with gr.Column(elem_classes="chat-container"):
|
166 |
+
chatbot = gr.Chatbot(
|
167 |
+
label="💬 Chat com Dr. Aldo",
|
168 |
+
elem_id="chat",
|
169 |
+
height="100%"
|
|
|
|
|
|
|
170 |
)
|
171 |
|
172 |
+
# Área de entrada - 20% da tela
|
173 |
+
with gr.Column(elem_classes="input-container"):
|
174 |
+
with gr.Row():
|
175 |
+
modelo_select = gr.Dropdown(
|
176 |
+
choices=list(MODELS.keys()),
|
177 |
+
value=DEFAULT_MODEL,
|
178 |
+
label="🧠 Selecione o Modelo de IA",
|
179 |
+
info="Escolha o modelo para responder",
|
180 |
+
elem_classes="modelo-dropdown"
|
181 |
+
)
|
182 |
+
|
183 |
+
with gr.Row():
|
184 |
+
user_input = gr.Textbox(
|
185 |
+
show_label=False,
|
186 |
+
placeholder="Digite sua pergunta e pressione Enter ou clique em Enviar",
|
187 |
+
lines=2,
|
188 |
+
elem_id="entrada_usuario"
|
189 |
+
)
|
190 |
+
enviar_btn = gr.Button("Enviar", variant="primary")
|
191 |
|
192 |
+
# Conteúdo adicional (fora da visualização inicial)
|
193 |
+
with gr.Column(elem_classes="additional-content"):
|
194 |
# RAG
|
195 |
with gr.Accordion("⚙️ Controle do Conhecimento (RAG)", open=False):
|
196 |
status_rag = gr.Textbox(label="Status do Retreino", interactive=False)
|