Spaces:
Running
Running
adiciona aba de Vídeo Showcase e novas traduções
Browse files
app.py
CHANGED
@@ -11,8 +11,8 @@ import plotly.express as px
|
|
11 |
import json
|
12 |
from io import StringIO
|
13 |
|
14 |
-
import dotenv
|
15 |
-
dotenv.load_dotenv()
|
16 |
|
17 |
# Importações adicionais para outros LLMs
|
18 |
try:
|
@@ -45,8 +45,8 @@ db_engine = None
|
|
45 |
db = None
|
46 |
llm = None
|
47 |
# db_chain = None # Substituído por agent_executor
|
48 |
-
agent_executor = None
|
49 |
-
chat_memory = None
|
50 |
|
51 |
# Sistema de tradução - dicionários de idiomas
|
52 |
TRANSLATIONS = {
|
@@ -55,6 +55,7 @@ TRANSLATIONS = {
|
|
55 |
"app_title": "SQLord - Converse com seu Banco de Dados PostgreSQL",
|
56 |
"chat_tab": "Chat com Banco",
|
57 |
"config_tab": "Configuração",
|
|
|
58 |
"question_placeholder": "Digite sua pergunta em linguagem natural sobre o banco de dados aqui... \nEx: Quantos usuários existem? Quais tabelas possuem a coluna 'nome'?",
|
59 |
"question_label": "Sua Pergunta",
|
60 |
"submit_button": "Enviar Pergunta",
|
@@ -153,6 +154,7 @@ TRANSLATIONS = {
|
|
153 |
"app_title": "SQLord - Talk to Your PostgreSQL Database",
|
154 |
"chat_tab": "Chat with Database",
|
155 |
"config_tab": "Configuration",
|
|
|
156 |
"question_placeholder": "Type your natural language question about the database here... \nEx: How many users exist? Which tables have the 'name' column?",
|
157 |
"question_label": "Your Question",
|
158 |
"submit_button": "Submit Question",
|
@@ -211,7 +213,7 @@ TRANSLATIONS = {
|
|
211 |
"no_viz_data": "No data for visualization",
|
212 |
|
213 |
# Mensagens do chat
|
214 |
-
"chat_intro": "Ask a question in natural language. The system (now with memory) will try to generate
|
215 |
"db_config": "DB Config: {config}",
|
216 |
"llm_status": "LLM Status: {status}",
|
217 |
"llm_not_operational": "LLM Status: {status} (Not operational)",
|
@@ -605,7 +607,8 @@ TRANSLATIONS["pt-BR"].update({
|
|
605 |
"max_iterations_label": "Máximo de iterações do agente",
|
606 |
"max_execution_time_label": "Tempo máximo de execução (segundos)",
|
607 |
"custom_prefix_label": "Prefixo personalizado para o prompt",
|
608 |
-
"advanced_settings_info": "Configurações avançadas aplicadas: top_k={top_k}, max_iterations={max_iterations}"
|
|
|
609 |
})
|
610 |
|
611 |
TRANSLATIONS["en-US"].update({
|
@@ -622,7 +625,8 @@ TRANSLATIONS["en-US"].update({
|
|
622 |
"max_iterations_label": "Maximum agent iterations",
|
623 |
"max_execution_time_label": "Maximum execution time (seconds)",
|
624 |
"custom_prefix_label": "Custom prompt prefix",
|
625 |
-
"advanced_settings_info": "Applied advanced settings: top_k={top_k}, max_iterations={max_iterations}"
|
|
|
626 |
})
|
627 |
|
628 |
# Histórico de chat como global para persistir entre interações
|
@@ -1063,6 +1067,11 @@ def main():
|
|
1063 |
llm_status_output, status_info]
|
1064 |
)
|
1065 |
|
|
|
|
|
|
|
|
|
|
|
1066 |
# SOLUÇÃO DEFINITIVA: Usar update_ui_on_language_change para atualizar textos
|
1067 |
def update_ui_on_language_change(language):
|
1068 |
"""
|
@@ -1100,6 +1109,8 @@ def main():
|
|
1100 |
max_execution_time_input: gr.update(label=_("max_execution_time_label")),
|
1101 |
custom_prefix_input: gr.update(label=_("custom_prefix_label")),
|
1102 |
db_schema_button: "Ver Esquema do Banco" if language == "pt-BR" else "View Database Schema",
|
|
|
|
|
1103 |
}
|
1104 |
|
1105 |
# Registrar a função para executar quando o idioma mudar
|
@@ -1113,7 +1124,7 @@ def main():
|
|
1113 |
connect_button, llm_status_output, connection_status_output,
|
1114 |
current_config_output, clear, advanced_settings_title, top_k_input,
|
1115 |
max_iterations_input, max_execution_time_input, custom_prefix_input,
|
1116 |
-
db_schema_button
|
1117 |
]
|
1118 |
)
|
1119 |
|
|
|
11 |
import json
|
12 |
from io import StringIO
|
13 |
|
14 |
+
import dotenv
|
15 |
+
dotenv.load_dotenv()
|
16 |
|
17 |
# Importações adicionais para outros LLMs
|
18 |
try:
|
|
|
45 |
db = None
|
46 |
llm = None
|
47 |
# db_chain = None # Substituído por agent_executor
|
48 |
+
agent_executor = None
|
49 |
+
chat_memory = None
|
50 |
|
51 |
# Sistema de tradução - dicionários de idiomas
|
52 |
TRANSLATIONS = {
|
|
|
55 |
"app_title": "SQLord - Converse com seu Banco de Dados PostgreSQL",
|
56 |
"chat_tab": "Chat com Banco",
|
57 |
"config_tab": "Configuração",
|
58 |
+
"video_tab": "Vídeo de Demonstração", # Nova tradução
|
59 |
"question_placeholder": "Digite sua pergunta em linguagem natural sobre o banco de dados aqui... \nEx: Quantos usuários existem? Quais tabelas possuem a coluna 'nome'?",
|
60 |
"question_label": "Sua Pergunta",
|
61 |
"submit_button": "Enviar Pergunta",
|
|
|
154 |
"app_title": "SQLord - Talk to Your PostgreSQL Database",
|
155 |
"chat_tab": "Chat with Database",
|
156 |
"config_tab": "Configuration",
|
157 |
+
"video_tab": "Video Showcase", # Nova tradução
|
158 |
"question_placeholder": "Type your natural language question about the database here... \nEx: How many users exist? Which tables have the 'name' column?",
|
159 |
"question_label": "Your Question",
|
160 |
"submit_button": "Submit Question",
|
|
|
213 |
"no_viz_data": "No data for visualization",
|
214 |
|
215 |
# Mensagens do chat
|
216 |
+
"chat_intro": "Ask a question in natural language. The system (now with memory) will try to generate anSQL query, execute it, and show the result.",
|
217 |
"db_config": "DB Config: {config}",
|
218 |
"llm_status": "LLM Status: {status}",
|
219 |
"llm_not_operational": "LLM Status: {status} (Not operational)",
|
|
|
607 |
"max_iterations_label": "Máximo de iterações do agente",
|
608 |
"max_execution_time_label": "Tempo máximo de execução (segundos)",
|
609 |
"custom_prefix_label": "Prefixo personalizado para o prompt",
|
610 |
+
"advanced_settings_info": "Configurações avançadas aplicadas: top_k={top_k}, max_iterations={max_iterations}",
|
611 |
+
"video_showcase_title": "### Demonstração em Vídeo" # Nova tradução
|
612 |
})
|
613 |
|
614 |
TRANSLATIONS["en-US"].update({
|
|
|
625 |
"max_iterations_label": "Maximum agent iterations",
|
626 |
"max_execution_time_label": "Maximum execution time (seconds)",
|
627 |
"custom_prefix_label": "Custom prompt prefix",
|
628 |
+
"advanced_settings_info": "Applied advanced settings: top_k={top_k}, max_iterations={max_iterations}",
|
629 |
+
"video_showcase_title": "### Video Showcase" # Nova tradução
|
630 |
})
|
631 |
|
632 |
# Histórico de chat como global para persistir entre interações
|
|
|
1067 |
llm_status_output, status_info]
|
1068 |
)
|
1069 |
|
1070 |
+
# Aba de Vídeo Showcase
|
1071 |
+
with gr.TabItem(_("video_tab")) as video_tab:
|
1072 |
+
video_title = gr.Markdown(_("video_showcase_title"))
|
1073 |
+
gr.HTML("""<iframe width="560" height="315" src="https://www.youtube.com/embed/T_tNgRTyY9g?si=RCF08AW2g8OdmH_l" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>""")
|
1074 |
+
|
1075 |
# SOLUÇÃO DEFINITIVA: Usar update_ui_on_language_change para atualizar textos
|
1076 |
def update_ui_on_language_change(language):
|
1077 |
"""
|
|
|
1109 |
max_execution_time_input: gr.update(label=_("max_execution_time_label")),
|
1110 |
custom_prefix_input: gr.update(label=_("custom_prefix_label")),
|
1111 |
db_schema_button: "Ver Esquema do Banco" if language == "pt-BR" else "View Database Schema",
|
1112 |
+
# Atualizar título da aba de vídeo
|
1113 |
+
video_title: _("video_showcase_title")
|
1114 |
}
|
1115 |
|
1116 |
# Registrar a função para executar quando o idioma mudar
|
|
|
1124 |
connect_button, llm_status_output, connection_status_output,
|
1125 |
current_config_output, clear, advanced_settings_title, top_k_input,
|
1126 |
max_iterations_input, max_execution_time_input, custom_prefix_input,
|
1127 |
+
db_schema_button, video_title # Adicionar video_title aos outputs
|
1128 |
]
|
1129 |
)
|
1130 |
|