iatoolkit 0.11.0__py3-none-any.whl → 0.66.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. iatoolkit/base_company.py +11 -3
  2. iatoolkit/common/routes.py +92 -52
  3. iatoolkit/common/session_manager.py +0 -1
  4. iatoolkit/common/util.py +17 -27
  5. iatoolkit/iatoolkit.py +91 -47
  6. iatoolkit/infra/llm_client.py +7 -8
  7. iatoolkit/infra/openai_adapter.py +1 -1
  8. iatoolkit/infra/redis_session_manager.py +48 -2
  9. iatoolkit/locales/en.yaml +144 -0
  10. iatoolkit/locales/es.yaml +140 -0
  11. iatoolkit/repositories/database_manager.py +17 -2
  12. iatoolkit/repositories/models.py +31 -4
  13. iatoolkit/repositories/profile_repo.py +7 -2
  14. iatoolkit/services/auth_service.py +193 -0
  15. iatoolkit/services/branding_service.py +59 -18
  16. iatoolkit/services/dispatcher_service.py +10 -40
  17. iatoolkit/services/excel_service.py +15 -15
  18. iatoolkit/services/help_content_service.py +30 -0
  19. iatoolkit/services/history_service.py +2 -11
  20. iatoolkit/services/i18n_service.py +104 -0
  21. iatoolkit/services/jwt_service.py +15 -24
  22. iatoolkit/services/language_service.py +77 -0
  23. iatoolkit/services/onboarding_service.py +43 -0
  24. iatoolkit/services/profile_service.py +148 -75
  25. iatoolkit/services/query_service.py +124 -81
  26. iatoolkit/services/tasks_service.py +1 -1
  27. iatoolkit/services/user_feedback_service.py +68 -32
  28. iatoolkit/services/user_session_context_service.py +112 -54
  29. iatoolkit/static/images/fernando.jpeg +0 -0
  30. iatoolkit/static/js/chat_feedback_button.js +80 -0
  31. iatoolkit/static/js/chat_help_content.js +124 -0
  32. iatoolkit/static/js/chat_history_button.js +112 -0
  33. iatoolkit/static/js/chat_logout_button.js +36 -0
  34. iatoolkit/static/js/chat_main.js +148 -220
  35. iatoolkit/static/js/chat_onboarding_button.js +97 -0
  36. iatoolkit/static/js/chat_prompt_manager.js +94 -0
  37. iatoolkit/static/js/chat_reload_button.js +35 -0
  38. iatoolkit/static/styles/chat_iatoolkit.css +367 -199
  39. iatoolkit/static/styles/chat_modal.css +98 -76
  40. iatoolkit/static/styles/chat_public.css +107 -0
  41. iatoolkit/static/styles/landing_page.css +182 -0
  42. iatoolkit/static/styles/onboarding.css +169 -0
  43. iatoolkit/system_prompts/query_main.prompt +3 -12
  44. iatoolkit/templates/_company_header.html +20 -0
  45. iatoolkit/templates/_login_widget.html +42 -0
  46. iatoolkit/templates/base.html +40 -20
  47. iatoolkit/templates/change_password.html +57 -36
  48. iatoolkit/templates/chat.html +169 -83
  49. iatoolkit/templates/chat_modals.html +134 -68
  50. iatoolkit/templates/error.html +44 -8
  51. iatoolkit/templates/forgot_password.html +40 -23
  52. iatoolkit/templates/index.html +145 -0
  53. iatoolkit/templates/login_simulation.html +34 -0
  54. iatoolkit/templates/onboarding_shell.html +104 -0
  55. iatoolkit/templates/signup.html +63 -65
  56. iatoolkit/views/base_login_view.py +92 -0
  57. iatoolkit/views/change_password_view.py +56 -30
  58. iatoolkit/views/external_login_view.py +61 -28
  59. iatoolkit/views/{file_store_view.py → file_store_api_view.py} +9 -2
  60. iatoolkit/views/forgot_password_view.py +27 -19
  61. iatoolkit/views/help_content_api_view.py +54 -0
  62. iatoolkit/views/history_api_view.py +56 -0
  63. iatoolkit/views/home_view.py +50 -23
  64. iatoolkit/views/index_view.py +14 -0
  65. iatoolkit/views/init_context_api_view.py +73 -0
  66. iatoolkit/views/llmquery_api_view.py +57 -0
  67. iatoolkit/views/login_simulation_view.py +81 -0
  68. iatoolkit/views/login_view.py +130 -37
  69. iatoolkit/views/logout_api_view.py +49 -0
  70. iatoolkit/views/profile_api_view.py +46 -0
  71. iatoolkit/views/{prompt_view.py → prompt_api_view.py} +10 -10
  72. iatoolkit/views/signup_view.py +42 -35
  73. iatoolkit/views/{tasks_view.py → tasks_api_view.py} +10 -36
  74. iatoolkit/views/tasks_review_api_view.py +55 -0
  75. iatoolkit/views/user_feedback_api_view.py +60 -0
  76. iatoolkit/views/verify_user_view.py +35 -28
  77. {iatoolkit-0.11.0.dist-info → iatoolkit-0.66.2.dist-info}/METADATA +2 -2
  78. iatoolkit-0.66.2.dist-info/RECORD +119 -0
  79. iatoolkit/common/auth.py +0 -200
  80. iatoolkit/static/images/arrow_up.png +0 -0
  81. iatoolkit/static/images/diagrama_iatoolkit.jpg +0 -0
  82. iatoolkit/static/images/logo_clinica.png +0 -0
  83. iatoolkit/static/images/logo_iatoolkit.png +0 -0
  84. iatoolkit/static/images/logo_maxxa.png +0 -0
  85. iatoolkit/static/images/logo_notaria.png +0 -0
  86. iatoolkit/static/images/logo_tarjeta.png +0 -0
  87. iatoolkit/static/images/logo_umayor.png +0 -0
  88. iatoolkit/static/images/upload.png +0 -0
  89. iatoolkit/static/js/chat_feedback.js +0 -115
  90. iatoolkit/static/js/chat_history.js +0 -117
  91. iatoolkit/static/styles/chat_info.css +0 -53
  92. iatoolkit/templates/header.html +0 -31
  93. iatoolkit/templates/home.html +0 -199
  94. iatoolkit/templates/login.html +0 -43
  95. iatoolkit/templates/test.html +0 -9
  96. iatoolkit/views/chat_token_request_view.py +0 -98
  97. iatoolkit/views/chat_view.py +0 -58
  98. iatoolkit/views/download_file_view.py +0 -58
  99. iatoolkit/views/external_chat_login_view.py +0 -95
  100. iatoolkit/views/history_view.py +0 -57
  101. iatoolkit/views/llmquery_view.py +0 -65
  102. iatoolkit/views/tasks_review_view.py +0 -83
  103. iatoolkit/views/user_feedback_view.py +0 -74
  104. iatoolkit-0.11.0.dist-info/RECORD +0 -110
  105. {iatoolkit-0.11.0.dist-info → iatoolkit-0.66.2.dist-info}/WHEEL +0 -0
  106. {iatoolkit-0.11.0.dist-info → iatoolkit-0.66.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,80 @@
1
+ $(document).ready(function () {
2
+ const feedbackModal = $('#feedbackModal');
3
+ $('#submit-feedback').on('click', function () {
4
+ sendFeedback(this);
5
+ });
6
+
7
+ // Evento para enviar el feedback
8
+ async function sendFeedback(submitButton) {
9
+ toastr.options = {"positionClass": "toast-bottom-right", "preventDuplicates": true};
10
+ const feedbackText = $('#feedback-text').val().trim();
11
+ const activeStars = $('.star.active').length;
12
+
13
+ if (!feedbackText) {
14
+ toastr.error(t_js('feedback_comment_error'));
15
+ return;
16
+ }
17
+
18
+ if (activeStars === 0) {
19
+ toastr.error(t_js('feedback_rating_error'));
20
+ return;
21
+ }
22
+
23
+ submitButton.disabled = true;
24
+
25
+ // call the IAToolkit API to send feedback
26
+ const data = {
27
+ "user_identifier": window.user_identifier,
28
+ "message": feedbackText,
29
+ "rating": activeStars,
30
+ };
31
+
32
+ const responseData = await callToolkit('/api/feedback', data, "POST");
33
+ if (responseData)
34
+ toastr.success(t_js('feedback_sent_success_body'), t_js('feedback_sent_success_title'));
35
+ else
36
+ toastr.error(t_js('feedback_sent_error'));
37
+
38
+ submitButton.disabled = false;
39
+ feedbackModal.modal('hide');
40
+ }
41
+
42
+ // Evento para abrir el modal de feedback
43
+ $('#send-feedback-button').on('click', function () {
44
+ $('#submit-feedback').prop('disabled', false);
45
+ $('.star').removeClass('active hover-active'); // Resetea estrellas
46
+ $('#feedback-text').val('');
47
+ feedbackModal.modal('show');
48
+ });
49
+
50
+ // Evento que se dispara DESPUÉS de que el modal se ha ocultado
51
+ $('#feedbackModal').on('hidden.bs.modal', function () {
52
+ $('#feedback-text').val('');
53
+ $('.star').removeClass('active');
54
+ });
55
+
56
+ // Function for the star rating system
57
+ window.gfg = function (rating) {
58
+ $('.star').removeClass('active');
59
+ $('.star').each(function (index) {
60
+ if (index < rating) {
61
+ $(this).addClass('active');
62
+ }
63
+ });
64
+ };
65
+
66
+ $('.star').hover(
67
+ function () {
68
+ const rating = $(this).data('rating');
69
+ $('.star').removeClass('hover-active');
70
+ $('.star').each(function (index) {
71
+ if ($(this).data('rating') <= rating) {
72
+ $(this).addClass('hover-active');
73
+ }
74
+ });
75
+ },
76
+ function () {
77
+ $('.star').removeClass('hover-active');
78
+ });
79
+
80
+ });
@@ -0,0 +1,124 @@
1
+ $(document).ready(function () {
2
+
3
+ let helpContent = null; // Variable para cachear el contenido de ayuda
4
+
5
+ // Evento de clic en el botón de ayuda
6
+ $('#open-help-button').on('click', async function () {
7
+ const helpModal = new bootstrap.Modal(document.getElementById('helpModal'));
8
+ const accordionContainer = $('#help-accordion-container');
9
+ const spinner = $('#help-spinner');
10
+
11
+ // Si el contenido no se ha cargado, hacer la llamada a la API
12
+ if (helpContent) {
13
+ // Si el contenido ya está cacheado, solo muestra el modal
14
+ helpModal.show();
15
+ return;
16
+ }
17
+
18
+ spinner.show();
19
+ accordionContainer.hide();
20
+ helpModal.show();
21
+
22
+ try {
23
+ const helpContent = await callToolkit('/api/help-content', {}, "POST");
24
+
25
+ if (!helpContent) {
26
+ toastr.error('No se pudo cargar la guía de uso. Por favor, intente más tarde.');
27
+ spinner.hide();
28
+ helpModal.hide();
29
+ return;
30
+ }
31
+
32
+ // Construir el HTML del acordeón y mostrarlo
33
+ buildHelpAccordion(helpContent);
34
+ spinner.hide();
35
+ accordionContainer.show();
36
+
37
+ } catch (error) {
38
+ console.error("Error al cargar el contenido de ayuda:", error);
39
+ toastr.error('Ocurrió un error de red al cargar la guía.');
40
+ spinner.hide();
41
+ helpModal.hide();
42
+ }
43
+ });
44
+
45
+ /**
46
+ * Construye dinámicamente el HTML para el acordeón de ayuda a partir de los datos.
47
+ * @param {object} data El objeto JSON con el contenido de ayuda.
48
+ */
49
+ function buildHelpAccordion(data) {
50
+ const container = $('#help-accordion-container');
51
+ container.empty(); // Limpiar cualquier contenido previo
52
+
53
+ let accordionHtml = '';
54
+
55
+ if (data.example_questions) {
56
+ let contentHtml = '';
57
+ data.example_questions.forEach(cat => {
58
+ contentHtml += `<h6 class="fw-bold">${cat.category}</h6><ul>`;
59
+ cat.questions.forEach(q => contentHtml += `<li>${q}</li>`);
60
+ contentHtml += `</ul>`;
61
+ });
62
+ accordionHtml += createAccordionItem('examples', 'Preguntas de Ejemplo', contentHtml, true);
63
+ }
64
+
65
+ if (data.data_sources) {
66
+ let contentHtml = '<dl>';
67
+ data.data_sources.forEach(p => {
68
+ contentHtml += `<dt>${p.source}</dt><dd>${p.description}</dd>`;
69
+ });
70
+ contentHtml += `</dl>`;
71
+ accordionHtml += createAccordionItem('sources', 'Datos disponibles', contentHtml );
72
+ }
73
+
74
+ if (data.best_practices) {
75
+ let contentHtml = '<dl>';
76
+ data.best_practices.forEach(p => {
77
+ contentHtml += `<dt>${p.title}</dt><dd>${p.description}`;
78
+ if (p.example) {
79
+ contentHtml += `<br><small class="text-muted"><em>Ej: "${p.example}"</em></small>`;
80
+ }
81
+ contentHtml += `</dd>`;
82
+ });
83
+ contentHtml += `</dl>`;
84
+ accordionHtml += createAccordionItem('practices', 'Mejores Prácticas', contentHtml);
85
+ }
86
+
87
+ if (data.capabilities) {
88
+ let contentHtml = `<div class="row">`;
89
+ contentHtml += `<div class="col-md-6"><h6 class="fw-bold">Puede hacer:</h6><ul>${data.capabilities.can_do.map(item => `<li>${item}</li>`).join('')}</ul></div>`;
90
+ contentHtml += `<div class="col-md-6"><h6 class="fw-bold">No puede hacer:</h6><ul>${data.capabilities.cannot_do.map(item => `<li>${item}</li>`).join('')}</ul></div>`;
91
+ contentHtml += `</div>`;
92
+ accordionHtml += createAccordionItem('capabilities', 'Capacidades y Límites', contentHtml);
93
+ }
94
+
95
+ container.html(accordionHtml);
96
+ }
97
+
98
+ /**
99
+ * Helper para crear un item del acordeón de Bootstrap.
100
+ * @param {string} id El ID base para los elementos.
101
+ * @param {string} title El título que se muestra en el botón del acordeón.
102
+ * @param {string} contentHtml El HTML que va dentro del cuerpo colapsable.
103
+ * @param {boolean} isOpen Si el item debe estar abierto por defecto.
104
+ * @returns {string} El string HTML del item del acordeón.
105
+ */
106
+ function createAccordionItem(id, title, contentHtml, isOpen = false) {
107
+ const showClass = isOpen ? 'show' : '';
108
+ const collapsedClass = isOpen ? '' : 'collapsed';
109
+
110
+ return `
111
+ <div class="accordion-item">
112
+ <h2 class="accordion-header" id="heading-${id}">
113
+ <button class="accordion-button ${collapsedClass}" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-${id}" aria-expanded="${isOpen}" aria-controls="collapse-${id}">
114
+ ${title}
115
+ </button>
116
+ </h2>
117
+ <div id="collapse-${id}" class="accordion-collapse collapse ${showClass}" aria-labelledby="heading-${id}" data-bs-parent="#help-accordion-container">
118
+ <div class="accordion-body">
119
+ ${contentHtml}
120
+ </div>
121
+ </div>
122
+ </div>`;
123
+ }
124
+ });
@@ -0,0 +1,112 @@
1
+ $(document).ready(function () {
2
+ // Evento para abrir el modal de historial
3
+ const historyModal = $('#historyModal');
4
+
5
+ $('#history-button').on('click', function() {
6
+ historyModal.modal('show');
7
+ loadHistory();
8
+ });
9
+
10
+
11
+ // Función para cargar el historial
12
+ async function loadHistory() {
13
+ const historyLoading = $('#history-loading');
14
+ const historyContent = $('#history-content');
15
+ const historyTable = historyContent.find('table');
16
+ const noHistoryMessage = $('#no-history-message');
17
+
18
+ // prepare UI for loading
19
+ historyLoading.show();
20
+ historyContent.hide();
21
+ historyTable.show();
22
+ noHistoryMessage.hide();
23
+
24
+ // cal the toolkit, handle the response and errors
25
+ const data = await callToolkit("/api/history", {}, "POST");
26
+
27
+ if (!data || !data.history) {
28
+ toastr.error(t_js('error_loading_history'));
29
+ historyModal.modal('hide');
30
+ return;
31
+ }
32
+
33
+ if (data.history.length === 0) {
34
+ historyTable.hide();
35
+ noHistoryMessage.show();
36
+ } else
37
+ displayAllHistory(data.history);
38
+
39
+ historyLoading.hide();
40
+ historyContent.show();
41
+ }
42
+
43
+ // Función para mostrar todo el historial
44
+ function displayAllHistory(historyData) {
45
+ const historyTableBody = $('#history-table-body');
46
+
47
+ historyTableBody.empty();
48
+
49
+ // Filtrar solo consultas que son strings simples
50
+ const filteredHistory = historyData.filter(item => {
51
+ try {
52
+ JSON.parse(item.query);
53
+ return false;
54
+ } catch (e) {
55
+ return true;
56
+ }
57
+ });
58
+
59
+ // Poblar la tabla
60
+ filteredHistory.forEach((item, index) => {
61
+ const icon = $('<i>').addClass('bi bi-pencil-fill');
62
+
63
+ const link = $('<a>')
64
+ .attr('href', 'javascript:void(0);')
65
+ .addClass('edit-pencil')
66
+ .attr('title', t_js('edit_query'))
67
+ .data('query', item.query)
68
+ .append(icon);
69
+
70
+ const row = $('<tr>').append(
71
+ $('<td>').addClass('text-nowrap').text(formatDate(item.created_at)),
72
+ $('<td>').text(item.query),
73
+ $('<td>').append(link),
74
+ );
75
+
76
+ historyTableBody.append(row);
77
+ });
78
+ }
79
+
80
+ function formatDate(dateString) {
81
+ const date = new Date(dateString);
82
+
83
+ const padTo2Digits = (num) => num.toString().padStart(2, '0');
84
+
85
+ const day = padTo2Digits(date.getDate());
86
+ const month = padTo2Digits(date.getMonth() + 1);
87
+ const year = date.getFullYear();
88
+ const hours = padTo2Digits(date.getHours());
89
+ const minutes = padTo2Digits(date.getMinutes());
90
+
91
+ return `${day}-${month} ${hours}:${minutes}`;
92
+ }
93
+
94
+ // event handler for the edit pencil icon
95
+ $('#history-table-body').on('click', '.edit-pencil', function() {
96
+ const queryText = $(this).data('query');
97
+
98
+ // copy the text to the chat input box
99
+ if (queryText) {
100
+ $('#question').val(queryText);
101
+ autoResizeTextarea($('#question')[0]);
102
+ $('#send-button').removeClass('disabled');
103
+
104
+ // Cerrar el modal
105
+ $('#historyModal').modal('hide');
106
+
107
+ // Hacer focus en el textarea
108
+ if (window.innerWidth > 768)
109
+ $('#question').focus();
110
+ }
111
+ });
112
+ });
@@ -0,0 +1,36 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const logoutButton = document.getElementById('logout-button');
3
+ if (!logoutButton) {
4
+ console.warn('El botón de logout con id "logout-button" no fue encontrado.');
5
+ return;
6
+ }
7
+
8
+ if (window.toastr) {
9
+ toastr.options = { "positionClass": "toast-bottom-right", "preventDuplicates": true };
10
+ }
11
+
12
+ logoutButton.addEventListener('click', async function(event) {
13
+ event.preventDefault();
14
+
15
+ try {
16
+ const apiPath = '/api/logout';
17
+ const data = await callToolkit(apiPath, null, 'GET');
18
+
19
+ // Procesar la respuesta
20
+ if (data && data.status === 'success' && data.url) {
21
+ window.top.location.href = data.url;
22
+ } else {
23
+ // Si algo falla, callToolkit usualmente muestra un error.
24
+ // Mostramos un toast como fallback.
25
+ if (window.toastr) {
26
+ toastr.error('No se pudo procesar el cierre de sesión. Por favor, intente de nuevo.');
27
+ }
28
+ }
29
+ } catch (error) {
30
+ console.error('Error durante el logout:', error);
31
+ if (window.toastr) {
32
+ toastr.error('Ocurrió un error de red al intentar cerrar sesión.');
33
+ }
34
+ }
35
+ });
36
+ });