iatoolkit 0.63.1__py3-none-any.whl → 0.69.0__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.

Potentially problematic release.


This version of iatoolkit might be problematic. Click here for more details.

Files changed (83) hide show
  1. iatoolkit/__init__.py +0 -2
  2. iatoolkit/base_company.py +1 -26
  3. iatoolkit/common/routes.py +11 -2
  4. iatoolkit/common/session_manager.py +2 -0
  5. iatoolkit/common/util.py +17 -0
  6. iatoolkit/company_registry.py +1 -2
  7. iatoolkit/iatoolkit.py +39 -6
  8. iatoolkit/locales/en.yaml +167 -0
  9. iatoolkit/locales/es.yaml +163 -0
  10. iatoolkit/repositories/database_manager.py +8 -3
  11. iatoolkit/repositories/document_repo.py +1 -1
  12. iatoolkit/repositories/models.py +1 -4
  13. iatoolkit/repositories/profile_repo.py +0 -4
  14. iatoolkit/services/auth_service.py +14 -9
  15. iatoolkit/services/branding_service.py +36 -24
  16. iatoolkit/services/company_context_service.py +145 -0
  17. iatoolkit/services/configuration_service.py +133 -0
  18. iatoolkit/services/dispatcher_service.py +51 -48
  19. iatoolkit/services/document_service.py +5 -2
  20. iatoolkit/services/excel_service.py +15 -11
  21. iatoolkit/services/file_processor_service.py +4 -12
  22. iatoolkit/services/history_service.py +8 -7
  23. iatoolkit/services/i18n_service.py +104 -0
  24. iatoolkit/services/jwt_service.py +7 -9
  25. iatoolkit/services/language_service.py +83 -0
  26. iatoolkit/services/load_documents_service.py +4 -4
  27. iatoolkit/services/mail_service.py +9 -4
  28. iatoolkit/services/profile_service.py +61 -38
  29. iatoolkit/services/prompt_manager_service.py +20 -16
  30. iatoolkit/services/query_service.py +19 -15
  31. iatoolkit/services/search_service.py +11 -4
  32. iatoolkit/services/sql_service.py +55 -25
  33. iatoolkit/services/user_feedback_service.py +16 -14
  34. iatoolkit/static/js/chat_feedback_button.js +57 -87
  35. iatoolkit/static/js/chat_help_content.js +124 -0
  36. iatoolkit/static/js/chat_history_button.js +48 -65
  37. iatoolkit/static/js/chat_main.js +27 -24
  38. iatoolkit/static/js/chat_onboarding_button.js +6 -0
  39. iatoolkit/static/js/chat_reload_button.js +28 -45
  40. iatoolkit/static/styles/chat_iatoolkit.css +223 -315
  41. iatoolkit/static/styles/chat_modal.css +63 -97
  42. iatoolkit/static/styles/chat_public.css +107 -0
  43. iatoolkit/static/styles/landing_page.css +0 -1
  44. iatoolkit/static/styles/onboarding.css +7 -0
  45. iatoolkit/templates/_company_header.html +6 -2
  46. iatoolkit/templates/_login_widget.html +42 -0
  47. iatoolkit/templates/base.html +34 -19
  48. iatoolkit/templates/change_password.html +22 -20
  49. iatoolkit/templates/chat.html +59 -27
  50. iatoolkit/templates/chat_modals.html +114 -74
  51. iatoolkit/templates/error.html +12 -13
  52. iatoolkit/templates/forgot_password.html +11 -7
  53. iatoolkit/templates/index.html +8 -3
  54. iatoolkit/templates/login_simulation.html +17 -6
  55. iatoolkit/templates/onboarding_shell.html +4 -2
  56. iatoolkit/templates/signup.html +14 -14
  57. iatoolkit/views/base_login_view.py +19 -9
  58. iatoolkit/views/change_password_view.py +50 -35
  59. iatoolkit/views/external_login_view.py +1 -1
  60. iatoolkit/views/forgot_password_view.py +21 -22
  61. iatoolkit/views/help_content_api_view.py +54 -0
  62. iatoolkit/views/history_api_view.py +13 -9
  63. iatoolkit/views/home_view.py +30 -39
  64. iatoolkit/views/init_context_api_view.py +16 -11
  65. iatoolkit/views/llmquery_api_view.py +38 -26
  66. iatoolkit/views/login_simulation_view.py +14 -2
  67. iatoolkit/views/login_view.py +52 -40
  68. iatoolkit/views/logout_api_view.py +26 -22
  69. iatoolkit/views/profile_api_view.py +46 -0
  70. iatoolkit/views/prompt_api_view.py +6 -6
  71. iatoolkit/views/signup_view.py +27 -27
  72. iatoolkit/views/user_feedback_api_view.py +19 -18
  73. iatoolkit/views/verify_user_view.py +29 -30
  74. {iatoolkit-0.63.1.dist-info → iatoolkit-0.69.0.dist-info}/METADATA +40 -22
  75. iatoolkit-0.69.0.dist-info/RECORD +120 -0
  76. iatoolkit-0.69.0.dist-info/licenses/LICENSE +21 -0
  77. iatoolkit/services/onboarding_service.py +0 -43
  78. iatoolkit/static/styles/chat_info.css +0 -53
  79. iatoolkit/templates/header.html +0 -31
  80. iatoolkit/templates/test.html +0 -9
  81. iatoolkit-0.63.1.dist-info/RECORD +0 -112
  82. {iatoolkit-0.63.1.dist-info → iatoolkit-0.69.0.dist-info}/WHEEL +0 -0
  83. {iatoolkit-0.63.1.dist-info → iatoolkit-0.69.0.dist-info}/top_level.txt +0 -0
iatoolkit/__init__.py CHANGED
@@ -10,7 +10,6 @@ from .iatoolkit import IAToolkit, current_iatoolkit, create_app
10
10
  # for registering the client companies
11
11
  from .company_registry import register_company
12
12
  from .base_company import BaseCompany
13
- from iatoolkit.repositories.database_manager import DatabaseManager
14
13
 
15
14
  # --- Services ---
16
15
  from iatoolkit.services.query_service import QueryService
@@ -27,7 +26,6 @@ __all__ = [
27
26
  'current_iatoolkit',
28
27
  'register_company',
29
28
  'BaseCompany',
30
- 'DatabaseManager',
31
29
  'QueryService',
32
30
  'SqlService',
33
31
  'ExcelService',
iatoolkit/base_company.py CHANGED
@@ -7,7 +7,6 @@
7
7
  from abc import ABC, abstractmethod
8
8
  from iatoolkit.repositories.profile_repo import ProfileRepo
9
9
  from iatoolkit.repositories.llm_query_repo import LLMQueryRepo
10
-
11
10
  from iatoolkit.services.prompt_manager_service import PromptService
12
11
  from iatoolkit.repositories.models import Company, Function, PromptCategory
13
12
  from iatoolkit import IAToolkit
@@ -22,22 +21,14 @@ class BaseCompany(ABC):
22
21
  self.prompt_service: PromptService = injector.get(PromptService)
23
22
  self.company: Company | None = None
24
23
 
25
- def _load_company_by_short_name(self, short_name: str) -> Company:
26
- self.company = self.profile_repo.get_company_by_short_name(short_name)
27
- return self.company
28
-
29
24
  def _create_company(self,
30
25
  short_name: str,
31
26
  name: str,
32
27
  parameters: dict | None = None,
33
- branding: dict | None = None,
34
- onboarding_cards: dict | None = None,
35
28
  ) -> Company:
36
29
  company_obj = Company(short_name=short_name,
37
30
  name=name,
38
- parameters=parameters,
39
- branding=branding,
40
- onboarding_cards=onboarding_cards)
31
+ parameters=parameters)
41
32
  self.company = self.profile_repo.create_company(company_obj)
42
33
  return self.company
43
34
 
@@ -77,17 +68,6 @@ class BaseCompany(ABC):
77
68
  **kwargs
78
69
  )
79
70
 
80
-
81
- @abstractmethod
82
- # initialize all the database tables needed
83
- def register_company(self):
84
- raise NotImplementedError("La subclase debe implementar el método create_company()")
85
-
86
- @abstractmethod
87
- # get context specific for this company
88
- def get_company_context(self, **kwargs) -> str:
89
- raise NotImplementedError("La subclase debe implementar el método get_company_context()")
90
-
91
71
  @abstractmethod
92
72
  # get context specific for this company
93
73
  def get_user_info(self, user_identifier: str) -> dict:
@@ -98,11 +78,6 @@ class BaseCompany(ABC):
98
78
  def handle_request(self, tag: str, params: dict) -> dict:
99
79
  raise NotImplementedError("La subclase debe implementar el método handle_request()")
100
80
 
101
- @abstractmethod
102
- # get context specific for the query
103
- def start_execution(self):
104
- raise NotImplementedError("La subclase debe implementar el método start_execution()")
105
-
106
81
  @abstractmethod
107
82
  # get context specific for the query
108
83
  def get_metadata_from_filename(self, filename: str) -> dict:
@@ -5,7 +5,6 @@
5
5
 
6
6
  from flask import render_template, redirect, url_for,send_from_directory, current_app, abort
7
7
  from flask import jsonify
8
- from iatoolkit.views.history_api_view import HistoryApiView
9
8
 
10
9
 
11
10
  # this function register all the views
@@ -24,6 +23,10 @@ def register_views(injector, app):
24
23
  from iatoolkit.views.file_store_api_view import FileStoreApiView
25
24
  from iatoolkit.views.user_feedback_api_view import UserFeedbackApiView
26
25
  from iatoolkit.views.prompt_api_view import PromptApiView
26
+ from iatoolkit.views.history_api_view import HistoryApiView
27
+ from iatoolkit.views.help_content_api_view import HelpContentApiView
28
+ from iatoolkit.views.profile_api_view import UserLanguageApiView # <-- Importa la nueva vista
29
+
27
30
  from iatoolkit.views.login_view import LoginView, FinalizeContextView
28
31
  from iatoolkit.views.external_login_view import ExternalLoginView, RedeemTokenApiView
29
32
  from iatoolkit.views.logout_api_view import LogoutApiView
@@ -53,6 +56,11 @@ def register_views(injector, app):
53
56
  view_func=FinalizeContextView.as_view('finalize_with_token')
54
57
  )
55
58
 
59
+ app.add_url_rule(
60
+ '/api/profile/language',
61
+ view_func=UserLanguageApiView.as_view('user_language_api')
62
+ )
63
+
56
64
  # logout
57
65
  app.add_url_rule('/<company_short_name>/api/logout',
58
66
  view_func=LogoutApiView.as_view('logout'))
@@ -79,9 +87,10 @@ def register_views(injector, app):
79
87
  # open the promt directory
80
88
  app.add_url_rule('/<company_short_name>/api/prompts', view_func=PromptApiView.as_view('prompt'))
81
89
 
82
- # feedback and history
90
+ # toolbar buttons
83
91
  app.add_url_rule('/<company_short_name>/api/feedback', view_func=UserFeedbackApiView.as_view('feedback'))
84
92
  app.add_url_rule('/<company_short_name>/api/history', view_func=HistoryApiView.as_view('history'))
93
+ app.add_url_rule('/<company_short_name>/api/help-content', view_func=HelpContentApiView.as_view('help-content'))
85
94
 
86
95
  # tasks management endpoints: create task, and review answer
87
96
  app.add_url_rule('/tasks', view_func=TaskApiView.as_view('tasks'))
@@ -3,6 +3,8 @@
3
3
  #
4
4
  # IAToolkit is open source software.
5
5
 
6
+ # This is the Flask connected session manager for IAToolkit
7
+
6
8
  from flask import session
7
9
 
8
10
  class SessionManager:
iatoolkit/common/util.py CHANGED
@@ -81,6 +81,23 @@ class Utility:
81
81
  f'No se pudo renderizar el template desde el string, error: {str(e)}') from e
82
82
 
83
83
 
84
+ def get_company_template(self, company_short_name: str, template_name: str) -> str:
85
+ # 1. get the path to the company specific template
86
+ template_path = os.path.join(os.getcwd(), f'companies/{company_short_name}/templates/{template_name}')
87
+ if not os.path.exists(template_path):
88
+ return None
89
+
90
+ # 2. read the file
91
+ try:
92
+ with open(template_path, 'r') as f:
93
+ template_string = f.read()
94
+
95
+ return template_string
96
+ except Exception as e:
97
+ logging.exception(e)
98
+ return None
99
+
100
+
84
101
  def serialize(self, obj):
85
102
  if isinstance(obj, datetime) or isinstance(obj, date):
86
103
  return obj.isoformat()
@@ -31,10 +31,9 @@ class CompanyRegistry:
31
31
 
32
32
  # save the created instance in the registry
33
33
  self._company_instances[company_key] = company_instance
34
- logging.info(f"company '{company_key}' instantiated")
35
34
 
36
35
  except Exception as e:
37
- logging.error(f"Error instanciando empresa {company_key}: {e}")
36
+ logging.error(f"Error while creating company instance for {company_key}: {e}")
38
37
  logging.exception(e)
39
38
  raise
40
39
 
iatoolkit/iatoolkit.py CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # IAToolkit is open source software.
5
5
 
6
- from flask import Flask, url_for
6
+ from flask import Flask, url_for, get_flashed_messages
7
7
  from flask_session import Session
8
8
  from flask_injector import FlaskInjector
9
9
  from flask_bcrypt import Bcrypt
@@ -19,7 +19,7 @@ from werkzeug.middleware.proxy_fix import ProxyFix
19
19
  from injector import Binder, Injector, singleton
20
20
  from importlib.metadata import version as _pkg_version, PackageNotFoundError
21
21
 
22
- IATOOLKIT_VERSION = "0.63.1"
22
+ IATOOLKIT_VERSION = "0.69.0"
23
23
 
24
24
  # global variable for the unique instance of IAToolkit
25
25
  _iatoolkit_instance: Optional['IAToolkit'] = None
@@ -96,6 +96,7 @@ class IAToolkit:
96
96
  self._setup_cors()
97
97
  self._setup_additional_services()
98
98
  self._setup_cli_commands()
99
+ self._setup_request_globals()
99
100
  self._setup_context_processors()
100
101
 
101
102
  # Step 8: define the download_dir for excel's
@@ -109,6 +110,22 @@ class IAToolkit:
109
110
  # get a value from the config dict or the environment variable
110
111
  return self.config.get(key, os.getenv(key, default))
111
112
 
113
+ def _setup_request_globals(self):
114
+ """
115
+ Configures functions to run before each request to set up
116
+ request-global variables, such as language.
117
+ """
118
+ injector = self._injector
119
+
120
+ @self.app.before_request
121
+ def set_request_language():
122
+ """
123
+ Determines and caches the language for the current request in g.lang.
124
+ """
125
+ from iatoolkit.services.language_service import LanguageService
126
+ language_service = injector.get(LanguageService)
127
+ language_service.get_current_language()
128
+
112
129
  def _setup_logging(self):
113
130
  # Lee el nivel de log desde una variable de entorno, con 'INFO' como valor por defecto.
114
131
  log_level_name = os.getenv('LOG_LEVEL', 'INFO').upper()
@@ -276,7 +293,6 @@ class IAToolkit:
276
293
  from iatoolkit.repositories.document_repo import DocumentRepo
277
294
  from iatoolkit.repositories.profile_repo import ProfileRepo
278
295
  from iatoolkit.repositories.llm_query_repo import LLMQueryRepo
279
-
280
296
  from iatoolkit.repositories.vs_repo import VSRepo
281
297
  from iatoolkit.repositories.tasks_repo import TaskRepo
282
298
 
@@ -299,6 +315,9 @@ class IAToolkit:
299
315
  from iatoolkit.services.jwt_service import JWTService
300
316
  from iatoolkit.services.dispatcher_service import Dispatcher
301
317
  from iatoolkit.services.branding_service import BrandingService
318
+ from iatoolkit.services.i18n_service import I18nService
319
+ from iatoolkit.services.language_service import LanguageService
320
+ from iatoolkit.services.configuration_service import ConfigurationService
302
321
 
303
322
  binder.bind(QueryService, to=QueryService)
304
323
  binder.bind(TaskService, to=TaskService)
@@ -312,6 +331,9 @@ class IAToolkit:
312
331
  binder.bind(JWTService, to=JWTService)
313
332
  binder.bind(Dispatcher, to=Dispatcher)
314
333
  binder.bind(BrandingService, to=BrandingService)
334
+ binder.bind(I18nService, to=I18nService)
335
+ binder.bind(LanguageService, to=LanguageService)
336
+ binder.bind(ConfigurationService, to=ConfigurationService)
315
337
 
316
338
  def _bind_infrastructure(self, binder: Binder):
317
339
  from iatoolkit.infra.llm_client import llmClient
@@ -338,9 +360,9 @@ class IAToolkit:
338
360
  # instantiate all the registered companies
339
361
  get_company_registry().instantiate_companies(self._injector)
340
362
 
341
- # use the dispatcher to start the execution of every company
363
+ # use the dispatcher to load the company config.yaml file and prepare the execution
342
364
  dispatcher = self._injector.get(Dispatcher)
343
- dispatcher.start_execution()
365
+ dispatcher.load_company_configs()
344
366
 
345
367
  def _setup_cli_commands(self):
346
368
  from iatoolkit.cli_commands import register_core_commands
@@ -366,8 +388,18 @@ class IAToolkit:
366
388
  def inject_globals():
367
389
  from iatoolkit.common.session_manager import SessionManager
368
390
  from iatoolkit.services.profile_service import ProfileService
391
+ from iatoolkit.services.i18n_service import I18nService
369
392
 
393
+ # Get services from the injector
370
394
  profile_service = self._injector.get(ProfileService)
395
+ i18n_service = self._injector.get(I18nService)
396
+
397
+ # The 't' function wrapper no longer needs to determine the language itself.
398
+ # It will be automatically handled by the refactored I18nService.
399
+ def translate_for_template(key: str, **kwargs):
400
+ return i18n_service.t(key, **kwargs)
401
+
402
+ # Get user profile if a session exists
371
403
  user_profile = profile_service.get_current_session_info().get('profile', {})
372
404
 
373
405
  return {
@@ -379,9 +411,10 @@ class IAToolkit:
379
411
  'user_is_local': user_profile.get('user_is_local'),
380
412
  'user_email': user_profile.get('user_email'),
381
413
  'iatoolkit_base_url': os.environ.get('IATOOLKIT_BASE_URL', ''),
414
+ 'flashed_messages': get_flashed_messages(with_categories=True),
415
+ 't': translate_for_template
382
416
  }
383
417
 
384
-
385
418
  def _get_default_static_folder(self) -> str:
386
419
  try:
387
420
  current_dir = os.path.dirname(os.path.abspath(__file__)) # .../src/iatoolkit
@@ -0,0 +1,167 @@
1
+ # Language: English
2
+ ui:
3
+ login_widget:
4
+ title: "Sign In"
5
+ welcome_message: "Enter your credentials or register to access Sample Company’s AI platform."
6
+ email_placeholder: "Email address"
7
+ password_placeholder: "Password"
8
+ login_button: "Login"
9
+ forgot_password_link: "Forgot your password?"
10
+ no_account_prompt: "Don't have an account?"
11
+ signup_link: "Sign Up"
12
+
13
+ signup:
14
+ title: "Create an Account"
15
+ subtitle: "Start your journey with us today."
16
+ first_name_label: "First Name"
17
+ last_name_label: "Last Name"
18
+ email_label: "Email Address"
19
+ password_label: "Password"
20
+ confirm_password_label: "Confirm Password"
21
+ signup_button: "Create Account"
22
+ already_have_account: "Already have an account?"
23
+ login_link: "Log In"
24
+ disclaimer: "🔒We value your privacy. Your data will be used exclusively for the operation of the platform."
25
+
26
+ forgot_password:
27
+ title: "Recover Password"
28
+ subtitle: "Enter your email address and we will send you a link to reset your password."
29
+ submit_button: "Send Recovery Link"
30
+ back_to_login: "Back to Login"
31
+
32
+ change_password:
33
+ title: "Create New Password"
34
+ subtitle: "You are changing the password for <strong>{email}</strong>."
35
+ temp_code_label: "Temporary Code"
36
+ temp_code_placeholder: "Check your email"
37
+ new_password_label: "New Password"
38
+ password_instructions: "Must contain at least 8 characters, an uppercase letter, a lowercase letter, a number, and a special character."
39
+ confirm_password_label: "Confirm New Password"
40
+ save_button: "Save Password"
41
+ back_to_home: "Back to home"
42
+
43
+ chat:
44
+ welcome_message: "Hello! How can I help you today?"
45
+ input_placeholder: "Type your query here..."
46
+ prompts_available: "Available prompts"
47
+
48
+ tooltips:
49
+ history: "History of my queries"
50
+ reload_context: "Force Context Reload"
51
+ feedback: "Your feedback is very important"
52
+ usage_guide: "Usage Guide"
53
+ onboarding: "How to ask better questions"
54
+ logout: "Log out"
55
+ use_prompt_assistant: "Use Prompt Assistant"
56
+ attach_files: "Attach files"
57
+ view_attached_files: "View attached files"
58
+ send: "Send"
59
+ stop: "Stop"
60
+
61
+ modals:
62
+ files_title: "Uploaded Files"
63
+ feedback_title: "Your Opinion is Important"
64
+ feedback_prompt: "How useful was the assistant's response?"
65
+ feedback_comment_label: "Your feedback helps us improve:"
66
+ feedback_comment_placeholder: "Write your opinion, suggestions, or comments here..."
67
+ history_title: "Query History"
68
+ history_table_date: "Date"
69
+ history_table_query: "Query"
70
+ loading_history: "Loading history..."
71
+ no_history_found: "No query history found."
72
+ help_title: "AI Assistant User Guide"
73
+
74
+ buttons:
75
+ cancel: "Close"
76
+ send: "Send"
77
+ stop: "Stop"
78
+
79
+ errors:
80
+ company_not_found: "The company {company_short_name} does not exist."
81
+ timeout: "timeout expired."
82
+ auth:
83
+ invalid_password: "The provided password is incorrect."
84
+ user_not_found: "A user with that email address was not found."
85
+ invalid_or_expired_token: "Invalid or expired token."
86
+ session_creation_failed: "Could not create user session."
87
+ authentication_required: "Authentication required. No session cookie or API Key provided."
88
+ invalid_api_key: "Invalid or inactive API Key."
89
+ no_user_identifier_api: "No user_identifier provided for API call."
90
+ templates:
91
+ company_not_found: "Company not found."
92
+ home_template_not_found: "The home page template for the company '{company_name}' is not configured."
93
+ template_not_found: "Template not found: '{template_name}'."
94
+
95
+ processing_error: "An error occurred while processing the custom home page template: {error}"
96
+ general:
97
+ unexpected_error: "An unexpected error has occurred. Please contact support."
98
+ unsupported_language: "The selected language is not supported."
99
+ signup:
100
+ company_not_found: "The company {company_name} does not exist."
101
+ incorrect_password_for_existing_user: "The password for the user {email} is incorrect."
102
+ user_already_registered: "The user with email '{email}' already exists in this company."
103
+ password_mismatch: "The passwords do not match. Please try again."
104
+ change_password:
105
+ token_expired: "The password change link has expired. Please request a new one."
106
+ password_mismatch: "The passwords do not match. Please try again."
107
+ invalid_temp_code: "The temporary code is not valid. Please check it or request a new one."
108
+ forgot_password:
109
+ user_not_registered: "The user with email {email} is not registered."
110
+ verification:
111
+ token_expired: "The verification link has expired. Please contact support if you need a new one."
112
+ user_not_found: "The user you are trying to verify does not exist."
113
+ validation:
114
+ password_too_short: "Password must be at least 8 characters long."
115
+ password_no_uppercase: "Password must contain at least one uppercase letter."
116
+ password_no_lowercase: "Password must contain at least one lowercase letter."
117
+ password_no_digit: "Password must contain at least one number."
118
+ password_no_special_char: "Password must contain at least one special character."
119
+
120
+ services:
121
+ no_text_file: "The file is not text or the encoding is not UTF-8"
122
+ no_output_file: "Missing output file name"
123
+ no_data_for_excel: "Missing data or it is not a list of dictionaries"
124
+ no_download_directory: "Temporary directory for saving Excel files is not configured"
125
+ cannot_create_excel: "Could not create the Excel file"
126
+ invalid_filename: "Invalid filename"
127
+ file_not_exist: "File not found"
128
+ path_is_not_a_file: "The path does not correspond to a file"
129
+ file_validation_error: "Error validating file"
130
+ user_not_authorized: "user is not authorized for this company"
131
+ account_not_verified: "Your account has not been verified. Please check your email."
132
+ missing_response_id: "Can not found 'previous_response_id' for '{company_short_name}/{user_identifier}'. Reinit context"
133
+
134
+
135
+ api_responses:
136
+ context_reloaded_success: "The context has been successfully reloaded."
137
+
138
+ services:
139
+ mail_sent: "Email sent successfully."
140
+ start_query: "Hello, what can I help you with today?"
141
+
142
+
143
+ flash_messages:
144
+ password_changed_success: "Your password has been successfully reset. You can now log in."
145
+ login_required: "Please log in to continue."
146
+ signup_success: "Registration successful. Please check your email to verify your account."
147
+ user_associated_success: "Existing user successfully associated with the new company."
148
+ account_verified_success: "Your account has been successfully verified. Welcome!"
149
+ forgot_password_success: "If your email is registered, you will receive a link to reset your password."
150
+
151
+ # Keys specifically for JavaScript
152
+ js_messages:
153
+ feedback_sent_success_title: "Feedback Sent"
154
+ feedback_sent_success_body: "Thank you for your feedback!"
155
+ feedback_sent_error: "Could not send feedback, please try again."
156
+ feedback_rating_error: "Please rate the assistant using the stars."
157
+ feedback_comment_error: "Please write your comment before sending."
158
+ context_reloaded: "Context has been reloaded."
159
+ error_loading_history: "An error occurred while loading the history."
160
+ request_aborted: "The response generation has been stopped."
161
+ processing_error: "An error occurred while processing the request."
162
+ server_comm_error: "Server communication error ({status}). Please try again later."
163
+ network_error: "A network error occurred. Please try again in a few moments."
164
+ unknown_server_error: "Unknown server error."
165
+ loading: "Loading..."
166
+ reload_init: "init reloading context in background..."
167
+ no_history_found: "No query history found."
@@ -0,0 +1,163 @@
1
+ # locales/es.yaml
2
+ ui:
3
+ login_widget:
4
+ title: "Iniciar Sesión"
5
+ welcome_message: "Ingresa tus credenciales o registrate para acceder a la plataforma IA de Sample Company."
6
+ email_placeholder: "Correo electrónico"
7
+ login_button: "Acceder"
8
+ forgot_password_link: "¿Olvidaste tu contraseña?"
9
+ no_account_prompt: "¿No tienes una cuenta?"
10
+ signup_link: "Regístrate"
11
+
12
+ signup:
13
+ title: "Crear una Cuenta"
14
+ subtitle: "Comienza tu viaje con nosotros hoy."
15
+ first_name_label: "Nombre"
16
+ last_name_label: "Apellido"
17
+ email_label: "Correo Electrónico"
18
+ password_label: "Contraseña"
19
+ confirm_password_label: "Confirmar Contraseña"
20
+ signup_button: "Crear Cuenta"
21
+ already_have_account: "¿Ya tienes una cuenta?"
22
+ login_link: "Inicia Sesión"
23
+ disclaimer: "🔒 Valoramos tu privacidad. Tus datos se usarán exclusivamente para el funcionamiento de la plataforma."
24
+
25
+ forgot_password:
26
+ title: "Recuperar Contraseña"
27
+ subtitle: "Ingresa tu correo electrónico y te enviaremos un enlace para restablecer tu contraseña."
28
+ submit_button: "Enviar Enlace de Recuperación"
29
+ back_to_login: "Volver a Iniciar Sesión"
30
+
31
+ change_password:
32
+ title: "Crear Nueva Contraseña"
33
+ subtitle: "Estás cambiando la contraseña para <strong>{email}</strong>."
34
+ temp_code_label: "Código Temporal"
35
+ temp_code_placeholder: "Revisa tu correo electrónico"
36
+ new_password_label: "Nueva Contraseña"
37
+ password_instructions: "Debe contener al menos 8 caracteres, mayúscula, minúscula, número y un carácter especial."
38
+ confirm_password_label: "Confirmar Nueva Contraseña"
39
+ save_button: "Guardar Contraseña"
40
+ back_to_home: "Volver al inicio"
41
+
42
+ chat:
43
+ welcome_message: "¡Hola! ¿En qué te puedo ayudar hoy?"
44
+ input_placeholder: "Escribe tu consulta aquí..."
45
+ prompts_available: "Prompts disponibles"
46
+
47
+ tooltips:
48
+ history: "Historial con mis consultas"
49
+ reload_context: "Forzar Recarga de Contexto"
50
+ feedback: "Tu feedback es muy importante"
51
+ usage_guide: "Guía de Uso"
52
+ onboarding: "Cómo preguntar mejor"
53
+ logout: "Cerrar sesión"
54
+ use_prompt_assistant: "Usar Asistente de Prompts"
55
+ attach_files: "Adjuntar archivos"
56
+ view_attached_files: "Ver archivos adjuntos"
57
+ modals:
58
+ files_title: "Archivos Cargados"
59
+ feedback_title: "Tu Opinión es Importante"
60
+ feedback_prompt: "¿Qué tan útil fue la respuesta del asistente?"
61
+ feedback_comment_label: "Tu comentario nos ayuda a mejorar:"
62
+ feedback_comment_placeholder: "Escribe aquí tu opinión, sugerencias o comentarios..."
63
+ history_title: "Historial de Consultas"
64
+ history_table_date: "Fecha"
65
+ history_table_query: "Consulta"
66
+ loading_history: "Cargando historial..."
67
+ no_history_found: "No se encontró historial de consultas."
68
+ help_title: "Guía de uso del Asistente IA"
69
+
70
+ buttons:
71
+ cancel: "Cerrar"
72
+ send: "Enviar"
73
+ stop: "Detener"
74
+
75
+ errors:
76
+ company_not_found: "La empresa {company_short_name} no existe."
77
+ timeout: "El tiempo de espera ha expirado."
78
+
79
+
80
+ auth:
81
+ invalid_password: "La contraseña proporcionada es incorrecta."
82
+ user_not_found: "No se encontró un usuario con ese correo."
83
+ invalid_or_expired_token: "Token inválido o expirado."
84
+ session_creation_failed: "No se pudo crear la sesión del usuario."
85
+ authentication_required: "Autenticación requerida. No se proporcionó cookie de sesión o clave de API."
86
+ invalid_api_key: "Clave de API inválida o inactiva."
87
+ no_user_identifier_api: "No se proporcionó user_identifier para la llamada a la API."
88
+ templates:
89
+ company_not_found: "Empresa no encontrada."
90
+ home_template_not_found: "La plantilla de la página de inicio para la empresa '{company_name}' no está configurada."
91
+ processing_error: "Error al procesar el template: {error}"
92
+ template_not_found: "No se encontro el template: '{template_name}'."
93
+
94
+ general:
95
+ unexpected_error: "Ha ocurrido un error inesperado: {error}."
96
+ unsupported_language: "El idioma seleccionado no es válido."
97
+ signup:
98
+ company_not_found: "La empresa {company_name} no existe."
99
+ incorrect_password_for_existing_user: "La contraseña para el usuario {email} es incorrecta."
100
+ user_already_registered: "El usuario con email '{email}' ya existe en esta empresa."
101
+ password_mismatch: "Las contraseñas no coinciden. Por favor, inténtalo de nuevo."
102
+ change_password:
103
+ token_expired: "El enlace de cambio de contraseña ha expirado. Por favor, solicita uno nuevo."
104
+ password_mismatch: "Las contraseñas no coinciden. Por favor, inténtalo nuevamente."
105
+ invalid_temp_code: "El código temporal no es válido. Por favor, verifica o solicita uno nuevo."
106
+ forgot_password:
107
+ user_not_registered: "El usuario con correo {email} no está registrado."
108
+ verification:
109
+ token_expired: "El enlace de verificación ha expirado. Por favor, contacta a soporte si necesitas uno nuevo."
110
+ user_not_found: "El usuario que intentas verificar no existe."
111
+ validation:
112
+ password_too_short: "La contraseña debe tener al menos 8 caracteres."
113
+ password_no_uppercase: "La contraseña debe tener al menos una letra mayúscula."
114
+ password_no_lowercase: "La contraseña debe tener al menos una letra minúscula."
115
+ password_no_digit: "La contraseña debe tener al menos un número."
116
+ password_no_special_char: "La contraseña debe tener al menos un carácter especial."
117
+
118
+ services:
119
+ no_text_file: "El archivo no es texto o la codificación no es UTF-8"
120
+ no_output_file: "falta el nombre del archivo de salida"
121
+ no_data_for_excel: "faltan los datos o no es una lista de diccionarios"
122
+ no_download_directory: "no esta configurado el directorio temporal para guardar excels"
123
+ cannot_create_excel: "no se pudo crear el archivo excel"
124
+ invalid_filename: "Nombre de archivo inválido"
125
+ file_not_exist : "Archivo no encontrado"
126
+ path_is_not_a_file : "La ruta no corresponde a un archivo"
127
+ file_validation_error : "Error validando archivo"
128
+ user_not_authorized: "Usuario no esta autorizado para esta empresa"
129
+ account_not_verified: "Tu cuenta no ha sido verificada. Por favor, revisa tu correo."
130
+ missing_response_id: "No se encontró 'previous_response_id' para '{company_short_name}/{user_identifier}'. Reinicia el contexto."
131
+
132
+ api_responses:
133
+ context_reloaded_success: "El contexto se ha recargado con éxito."
134
+
135
+ services:
136
+ mail_sent: "mail enviado exitosamente."
137
+ start_query: "Hola, cual es tu pregunta?"
138
+
139
+ flash_messages:
140
+ password_changed_success: "Tu contraseña ha sido restablecida exitosamente. Ahora puedes iniciar sesión."
141
+ signup_success: "Registro exitoso. Por favor, revisa tu correo para verificar tu cuenta."
142
+ user_associated_success: "Usuario existente asociado exitosamente a la nueva empresa."
143
+ account_verified_success: "Tu cuenta ha sido verificada exitosamente. ¡Bienvenido!"
144
+ forgot_password_success: "Si tu correo está registrado, recibirás un enlace para restablecer tu contraseña."
145
+
146
+ # Claves específicas para JavaScript
147
+ js_messages:
148
+ feedback_sent_success_title: "Feedback Enviado"
149
+ feedback_sent_success_body: "¡Gracias por tu comentario!"
150
+ feedback_sent_error: "No se pudo enviar el feedback, por favor intente nuevamente."
151
+ feedback_rating_error: "Por favor, califica al asistente con las estrellas."
152
+ feedback_comment_error: "Por favor, escribe tu comentario antes de enviar."
153
+ context_reloaded: "El contexto ha sido recargado."
154
+ error_loading_history: "Ocurrió un error al cargar el historial."
155
+ request_aborted: "La generación de la respuesta ha sido detenida."
156
+ processing_error: "Ocurrió un error al procesar la solicitud."
157
+ server_comm_error: "Error de comunicación con el servidor ({status}). Por favor, intente de nuevo más tarde."
158
+ network_error: "Ocurrió un error de red. Por favor, inténtalo de nuevo en unos momentos."
159
+ unknown_server_error: "Error desconocido del servidor."
160
+ loading: "Cargando..."
161
+ reload_init: "Iniciando recarga de contexto en segundo plano..."
162
+ no_history_found: "No existe historial de consultas."
163
+
@@ -27,8 +27,8 @@ class DatabaseManager:
27
27
  self._engine = create_engine(
28
28
  database_url,
29
29
  echo=False,
30
- pool_size=2, # per worker
31
- max_overflow=3,
30
+ pool_size=10, # per worker
31
+ max_overflow=20,
32
32
  pool_timeout=30,
33
33
  pool_recycle=1800,
34
34
  pool_pre_ping=True,
@@ -70,6 +70,11 @@ class DatabaseManager:
70
70
  def remove_session(self):
71
71
  self.scoped_session.remove()
72
72
 
73
+ def get_all_table_names(self) -> list[str]:
74
+ # Returns a list of all table names in the database
75
+ inspector = inspect(self._engine)
76
+ return inspector.get_table_names()
77
+
73
78
  def get_table_schema(self,
74
79
  table_name: str,
75
80
  schema_name: str | None = None,
@@ -77,7 +82,7 @@ class DatabaseManager:
77
82
  inspector = inspect(self._engine)
78
83
 
79
84
  if table_name not in inspector.get_table_names():
80
- raise RuntimeError(f"La tabla '{table_name}' no existe en la BD.")
85
+ raise RuntimeError(f"Table '{table_name}' does not exist.")
81
86
 
82
87
  if exclude_columns is None:
83
88
  exclude_columns = []
@@ -22,7 +22,7 @@ class DocumentRepo:
22
22
  def get(self, company_id, filename: str ) -> Document:
23
23
  if not company_id or not filename:
24
24
  raise IAToolkitException(IAToolkitException.ErrorType.PARAM_NOT_FILLED,
25
- 'Falta empresa o filename')
25
+ 'missing company_id or filename')
26
26
 
27
27
  return self.session.query(Document).filter_by(company_id=company_id, filename=filename).first()
28
28