iatoolkit 0.71.4__py3-none-any.whl → 1.4.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.
- iatoolkit/__init__.py +19 -7
- iatoolkit/base_company.py +1 -71
- iatoolkit/cli_commands.py +9 -21
- iatoolkit/common/exceptions.py +2 -0
- iatoolkit/common/interfaces/__init__.py +0 -0
- iatoolkit/common/interfaces/asset_storage.py +34 -0
- iatoolkit/common/interfaces/database_provider.py +38 -0
- iatoolkit/common/model_registry.py +159 -0
- iatoolkit/common/routes.py +53 -32
- iatoolkit/common/util.py +17 -12
- iatoolkit/company_registry.py +55 -14
- iatoolkit/{iatoolkit.py → core.py} +102 -72
- iatoolkit/infra/{mail_app.py → brevo_mail_app.py} +15 -37
- iatoolkit/infra/llm_providers/__init__.py +0 -0
- iatoolkit/infra/llm_providers/deepseek_adapter.py +278 -0
- iatoolkit/infra/{gemini_adapter.py → llm_providers/gemini_adapter.py} +11 -17
- iatoolkit/infra/{openai_adapter.py → llm_providers/openai_adapter.py} +41 -7
- iatoolkit/infra/llm_proxy.py +235 -134
- iatoolkit/infra/llm_response.py +5 -0
- iatoolkit/locales/en.yaml +134 -4
- iatoolkit/locales/es.yaml +293 -162
- iatoolkit/repositories/database_manager.py +92 -22
- iatoolkit/repositories/document_repo.py +7 -0
- iatoolkit/repositories/filesystem_asset_repository.py +36 -0
- iatoolkit/repositories/llm_query_repo.py +36 -22
- iatoolkit/repositories/models.py +86 -95
- iatoolkit/repositories/profile_repo.py +64 -13
- iatoolkit/repositories/vs_repo.py +31 -28
- iatoolkit/services/auth_service.py +1 -1
- iatoolkit/services/branding_service.py +1 -1
- iatoolkit/services/company_context_service.py +96 -39
- iatoolkit/services/configuration_service.py +329 -67
- iatoolkit/services/dispatcher_service.py +51 -227
- iatoolkit/services/document_service.py +10 -1
- iatoolkit/services/embedding_service.py +9 -6
- iatoolkit/services/excel_service.py +50 -2
- iatoolkit/services/file_processor_service.py +0 -5
- iatoolkit/services/history_manager_service.py +208 -0
- iatoolkit/services/jwt_service.py +1 -1
- iatoolkit/services/knowledge_base_service.py +412 -0
- iatoolkit/services/language_service.py +8 -2
- iatoolkit/services/license_service.py +82 -0
- iatoolkit/{infra/llm_client.py → services/llm_client_service.py} +42 -29
- iatoolkit/services/load_documents_service.py +18 -47
- iatoolkit/services/mail_service.py +171 -25
- iatoolkit/services/profile_service.py +69 -36
- iatoolkit/services/{prompt_manager_service.py → prompt_service.py} +136 -25
- iatoolkit/services/query_service.py +229 -203
- iatoolkit/services/sql_service.py +116 -34
- iatoolkit/services/tool_service.py +246 -0
- iatoolkit/services/user_feedback_service.py +18 -6
- iatoolkit/services/user_session_context_service.py +121 -51
- iatoolkit/static/images/iatoolkit_core.png +0 -0
- iatoolkit/static/images/iatoolkit_logo.png +0 -0
- iatoolkit/static/js/chat_feedback_button.js +1 -1
- iatoolkit/static/js/chat_help_content.js +4 -4
- iatoolkit/static/js/chat_main.js +61 -9
- iatoolkit/static/js/chat_model_selector.js +227 -0
- iatoolkit/static/js/chat_onboarding_button.js +1 -1
- iatoolkit/static/js/chat_reload_button.js +4 -1
- iatoolkit/static/styles/chat_iatoolkit.css +59 -3
- iatoolkit/static/styles/chat_public.css +28 -0
- iatoolkit/static/styles/documents.css +598 -0
- iatoolkit/static/styles/landing_page.css +223 -7
- iatoolkit/static/styles/llm_output.css +34 -1
- iatoolkit/system_prompts/__init__.py +0 -0
- iatoolkit/system_prompts/query_main.prompt +28 -3
- iatoolkit/system_prompts/sql_rules.prompt +47 -12
- iatoolkit/templates/_company_header.html +30 -5
- iatoolkit/templates/_login_widget.html +3 -3
- iatoolkit/templates/base.html +13 -0
- iatoolkit/templates/chat.html +45 -3
- iatoolkit/templates/forgot_password.html +3 -2
- iatoolkit/templates/onboarding_shell.html +1 -2
- iatoolkit/templates/signup.html +3 -0
- iatoolkit/views/base_login_view.py +8 -3
- iatoolkit/views/change_password_view.py +1 -1
- iatoolkit/views/chat_view.py +76 -0
- iatoolkit/views/forgot_password_view.py +9 -4
- iatoolkit/views/history_api_view.py +3 -3
- iatoolkit/views/home_view.py +4 -2
- iatoolkit/views/init_context_api_view.py +1 -1
- iatoolkit/views/llmquery_api_view.py +4 -3
- iatoolkit/views/load_company_configuration_api_view.py +49 -0
- iatoolkit/views/{file_store_api_view.py → load_document_api_view.py} +15 -11
- iatoolkit/views/login_view.py +25 -8
- iatoolkit/views/logout_api_view.py +10 -2
- iatoolkit/views/prompt_api_view.py +1 -1
- iatoolkit/views/rag_api_view.py +216 -0
- iatoolkit/views/root_redirect_view.py +22 -0
- iatoolkit/views/signup_view.py +12 -4
- iatoolkit/views/static_page_view.py +27 -0
- iatoolkit/views/users_api_view.py +33 -0
- iatoolkit/views/verify_user_view.py +1 -1
- iatoolkit-1.4.2.dist-info/METADATA +268 -0
- iatoolkit-1.4.2.dist-info/RECORD +133 -0
- iatoolkit-1.4.2.dist-info/licenses/LICENSE_COMMUNITY.md +15 -0
- iatoolkit/repositories/tasks_repo.py +0 -52
- iatoolkit/services/history_service.py +0 -37
- iatoolkit/services/search_service.py +0 -55
- iatoolkit/services/tasks_service.py +0 -188
- iatoolkit/templates/about.html +0 -13
- iatoolkit/templates/index.html +0 -145
- iatoolkit/templates/login_simulation.html +0 -45
- iatoolkit/views/external_login_view.py +0 -73
- iatoolkit/views/index_view.py +0 -14
- iatoolkit/views/login_simulation_view.py +0 -93
- iatoolkit/views/tasks_api_view.py +0 -72
- iatoolkit/views/tasks_review_api_view.py +0 -55
- iatoolkit-0.71.4.dist-info/METADATA +0 -276
- iatoolkit-0.71.4.dist-info/RECORD +0 -122
- {iatoolkit-0.71.4.dist-info → iatoolkit-1.4.2.dist-info}/WHEEL +0 -0
- {iatoolkit-0.71.4.dist-info → iatoolkit-1.4.2.dist-info}/licenses/LICENSE +0 -0
- {iatoolkit-0.71.4.dist-info → iatoolkit-1.4.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Copyright (c) 2024 Fernando Libedinsky
|
|
2
|
+
# Product: IAToolkit
|
|
3
|
+
#
|
|
4
|
+
# IAToolkit is open source software.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
from iatoolkit.common.exceptions import IAToolkitException
|
|
8
|
+
from iatoolkit.services.knowledge_base_service import KnowledgeBaseService
|
|
9
|
+
from iatoolkit.services.auth_service import AuthService
|
|
10
|
+
from iatoolkit.common.util import Utility
|
|
11
|
+
from iatoolkit.services.i18n_service import I18nService
|
|
12
|
+
from flask import request, jsonify, send_file
|
|
13
|
+
from flask.views import MethodView
|
|
14
|
+
from injector import inject
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
import io
|
|
17
|
+
import mimetypes
|
|
18
|
+
|
|
19
|
+
class RagApiView(MethodView):
|
|
20
|
+
"""
|
|
21
|
+
API Endpoints for managing the RAG Knowledge Base.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
@inject
|
|
25
|
+
def __init__(self,
|
|
26
|
+
knowledge_base_service: KnowledgeBaseService,
|
|
27
|
+
auth_service: AuthService,
|
|
28
|
+
i18n_service: I18nService,
|
|
29
|
+
utility: Utility):
|
|
30
|
+
self.knowledge_base_service = knowledge_base_service
|
|
31
|
+
self.auth_service = auth_service
|
|
32
|
+
self.utility = utility
|
|
33
|
+
self.i18n_service = i18n_service
|
|
34
|
+
|
|
35
|
+
def dispatch_request(self, *args, **kwargs):
|
|
36
|
+
"""
|
|
37
|
+
Sobreescribimos el dispatch para soportar el mapeo de acciones personalizadas
|
|
38
|
+
pasadas a través de 'defaults' en add_url_rule (ej: action='list_files').
|
|
39
|
+
"""
|
|
40
|
+
action = kwargs.pop('action', None)
|
|
41
|
+
if action:
|
|
42
|
+
method = getattr(self, action, None)
|
|
43
|
+
if method:
|
|
44
|
+
return method(*args, **kwargs)
|
|
45
|
+
else:
|
|
46
|
+
raise AttributeError(self.i18n_service.t('rag.management.action_not_found', action=action))
|
|
47
|
+
|
|
48
|
+
return super().dispatch_request(*args, **kwargs)
|
|
49
|
+
|
|
50
|
+
def list_files(self, company_short_name):
|
|
51
|
+
"""
|
|
52
|
+
POST /api/rag/<company_short_name>/files
|
|
53
|
+
Returns a paginated list of documents based on filters provided in the JSON body.
|
|
54
|
+
"""
|
|
55
|
+
try:
|
|
56
|
+
# 1. Authenticate the user from the current session.
|
|
57
|
+
auth_result = self.auth_service.verify()
|
|
58
|
+
if not auth_result.get("success"):
|
|
59
|
+
return jsonify(auth_result), auth_result.get("status_code")
|
|
60
|
+
|
|
61
|
+
# 2. Parse Input
|
|
62
|
+
data = request.get_json() or {}
|
|
63
|
+
|
|
64
|
+
status = data.get('status', [])
|
|
65
|
+
user_identifier = data.get('user_identifier')
|
|
66
|
+
keyword = data.get('filename_keyword')
|
|
67
|
+
from_date_str = data.get('from_date')
|
|
68
|
+
to_date_str = data.get('to_date')
|
|
69
|
+
collection = data.get('collection', '')
|
|
70
|
+
limit = int(data.get('limit', 100))
|
|
71
|
+
offset = int(data.get('offset', 0))
|
|
72
|
+
|
|
73
|
+
from_date = datetime.fromisoformat(from_date_str) if from_date_str else None
|
|
74
|
+
to_date = datetime.fromisoformat(to_date_str) if to_date_str else None
|
|
75
|
+
|
|
76
|
+
# 3. Call Service
|
|
77
|
+
documents = self.knowledge_base_service.list_documents(
|
|
78
|
+
company_short_name=company_short_name,
|
|
79
|
+
status=status,
|
|
80
|
+
collection=collection,
|
|
81
|
+
filename_keyword=keyword,
|
|
82
|
+
user_identifier=user_identifier,
|
|
83
|
+
from_date=from_date,
|
|
84
|
+
to_date=to_date,
|
|
85
|
+
limit=limit,
|
|
86
|
+
offset=offset
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# 4. Format Response
|
|
90
|
+
response_list = []
|
|
91
|
+
for doc in documents:
|
|
92
|
+
response_list.append({
|
|
93
|
+
'id': doc.id,
|
|
94
|
+
'filename': doc.filename,
|
|
95
|
+
'user_identifier': doc.user_identifier,
|
|
96
|
+
'status': doc.status.value if hasattr(doc.status, 'value') else str(doc.status),
|
|
97
|
+
'created_at': doc.created_at.isoformat() if doc.created_at else None,
|
|
98
|
+
'metadata': doc.meta,
|
|
99
|
+
'error_message': doc.error_message,
|
|
100
|
+
'collection': doc.collection_type.name if doc.collection_type else None,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
return jsonify({
|
|
104
|
+
'result': 'success',
|
|
105
|
+
'count': len(response_list),
|
|
106
|
+
'documents': response_list
|
|
107
|
+
}), 200
|
|
108
|
+
|
|
109
|
+
except IAToolkitException as e:
|
|
110
|
+
return jsonify({'result': 'error', 'message': e.message}), e.http_code
|
|
111
|
+
except Exception as e:
|
|
112
|
+
return jsonify({'result': 'error', 'message': str(e)}), 500
|
|
113
|
+
|
|
114
|
+
def get_file_content(self, company_short_name, document_id):
|
|
115
|
+
"""
|
|
116
|
+
GET /api/rag/<company_short_name>/files/<document_id>/content
|
|
117
|
+
Streams the file content to the browser (inline view preferred).
|
|
118
|
+
"""
|
|
119
|
+
try:
|
|
120
|
+
# 1. Authenticate
|
|
121
|
+
auth_result = self.auth_service.verify()
|
|
122
|
+
if not auth_result.get("success"):
|
|
123
|
+
return jsonify(auth_result), auth_result.get("status_code")
|
|
124
|
+
|
|
125
|
+
# 2. Get content from service
|
|
126
|
+
file_bytes, filename = self.knowledge_base_service.get_document_content(document_id)
|
|
127
|
+
|
|
128
|
+
if not file_bytes:
|
|
129
|
+
msg = self.i18n_service.t('rag.management.not_found')
|
|
130
|
+
return jsonify({'result': 'error', 'message': msg}), 404
|
|
131
|
+
|
|
132
|
+
# 3. Determine MIME type
|
|
133
|
+
mime_type, _ = mimetypes.guess_type(filename)
|
|
134
|
+
if not mime_type:
|
|
135
|
+
mime_type = 'application/octet-stream'
|
|
136
|
+
|
|
137
|
+
# 4. Stream response
|
|
138
|
+
return send_file(
|
|
139
|
+
io.BytesIO(file_bytes),
|
|
140
|
+
mimetype=mime_type,
|
|
141
|
+
as_attachment=False, # Inline view
|
|
142
|
+
download_name=filename
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
except IAToolkitException as e:
|
|
146
|
+
return jsonify({'result': 'error', 'message': e.message}), e.http_code
|
|
147
|
+
except Exception as e:
|
|
148
|
+
return jsonify({'result': 'error', 'message': str(e)}), 500
|
|
149
|
+
|
|
150
|
+
def delete_file(self, company_short_name, document_id):
|
|
151
|
+
"""
|
|
152
|
+
DELETE /api/rag/<company_short_name>/files/<document_id>
|
|
153
|
+
Deletes a document and its vectors.
|
|
154
|
+
"""
|
|
155
|
+
try:
|
|
156
|
+
# 1. Authenticate
|
|
157
|
+
auth_result = self.auth_service.verify()
|
|
158
|
+
if not auth_result.get("success"):
|
|
159
|
+
return jsonify(auth_result), auth_result.get("status_code")
|
|
160
|
+
|
|
161
|
+
# 2. Call Service
|
|
162
|
+
success = self.knowledge_base_service.delete_document(document_id)
|
|
163
|
+
|
|
164
|
+
if success:
|
|
165
|
+
msg = self.i18n_service.t('rag.management.delete_success')
|
|
166
|
+
return jsonify({'result': 'success', 'message': msg}), 200
|
|
167
|
+
else:
|
|
168
|
+
msg = self.i18n_service.t('rag.management.not_found')
|
|
169
|
+
return jsonify({'result': 'error', 'message': msg}), 404
|
|
170
|
+
|
|
171
|
+
except IAToolkitException as e:
|
|
172
|
+
return jsonify({'result': 'error', 'message': e.message}), e.http_code
|
|
173
|
+
except Exception as e:
|
|
174
|
+
return jsonify({'result': 'error', 'message': str(e)}), 500
|
|
175
|
+
|
|
176
|
+
def search(self, company_short_name):
|
|
177
|
+
"""
|
|
178
|
+
POST /api/rag/<company_short_name>/search
|
|
179
|
+
Synchronous semantic search for the "Search Lab" UI.
|
|
180
|
+
Returns detailed chunks with text and metadata using search_raw.
|
|
181
|
+
"""
|
|
182
|
+
try:
|
|
183
|
+
# 1. Authenticate
|
|
184
|
+
auth_result = self.auth_service.verify()
|
|
185
|
+
if not auth_result.get("success"):
|
|
186
|
+
return jsonify(auth_result), auth_result.get("status_code")
|
|
187
|
+
|
|
188
|
+
# 2. Parse Input
|
|
189
|
+
data = request.get_json() or {}
|
|
190
|
+
query = data.get('query')
|
|
191
|
+
n_results = int(data.get('k', 5))
|
|
192
|
+
collection = data.get('collection')
|
|
193
|
+
metadata_filter = data.get('metadata_filter')
|
|
194
|
+
|
|
195
|
+
if not query:
|
|
196
|
+
msg = self.i18n_service.t('rag.search.query_required')
|
|
197
|
+
return jsonify({'result': 'error', 'message': msg}), 400
|
|
198
|
+
|
|
199
|
+
# 3. Call Service
|
|
200
|
+
chunks = self.knowledge_base_service.search_raw(
|
|
201
|
+
company_short_name=company_short_name,
|
|
202
|
+
query=query,
|
|
203
|
+
n_results=n_results,
|
|
204
|
+
collection=collection,
|
|
205
|
+
metadata_filter=metadata_filter,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
return jsonify({
|
|
209
|
+
"result": "success",
|
|
210
|
+
"chunks": chunks
|
|
211
|
+
}), 200
|
|
212
|
+
|
|
213
|
+
except IAToolkitException as e:
|
|
214
|
+
return jsonify({'result': 'error', 'error_message': e.message}), 501
|
|
215
|
+
except Exception as e:
|
|
216
|
+
return jsonify({'result': 'error', 'error_message': str(e)}), 500
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from flask import redirect, url_for
|
|
2
|
+
from flask.views import MethodView
|
|
3
|
+
from iatoolkit.company_registry import get_company_registry
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RootRedirectView(MethodView):
|
|
7
|
+
"""
|
|
8
|
+
Vista que redirige la raíz '/' al home de la primera compañía disponible.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def get(self):
|
|
12
|
+
registry = get_company_registry()
|
|
13
|
+
companies = registry.get_all_company_instances()
|
|
14
|
+
|
|
15
|
+
if companies:
|
|
16
|
+
# Obtener el short_name de la primera compañía registrada.
|
|
17
|
+
# En Python 3.7+, los diccionarios mantienen el orden de inserción.
|
|
18
|
+
first_company_short_name = next(iter(companies))
|
|
19
|
+
return redirect(url_for('home', company_short_name=first_company_short_name))
|
|
20
|
+
|
|
21
|
+
# Fallback: Si no hay compañías, ir al index genérico (o a un 404)
|
|
22
|
+
return redirect(url_for('index'))
|
iatoolkit/views/signup_view.py
CHANGED
|
@@ -22,7 +22,7 @@ class SignupView(MethodView):
|
|
|
22
22
|
self.branding_service = branding_service # 3. Guardar la instancia
|
|
23
23
|
self.i18n_service = i18n_service
|
|
24
24
|
|
|
25
|
-
self.serializer = URLSafeTimedSerializer(os.getenv("
|
|
25
|
+
self.serializer = URLSafeTimedSerializer(os.getenv("IATOOLKIT_SECRET_KEY"))
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def get(self, company_short_name: str):
|
|
@@ -33,9 +33,12 @@ class SignupView(MethodView):
|
|
|
33
33
|
message=self.i18n_service.t('errors.templates.company_not_found')), 404
|
|
34
34
|
|
|
35
35
|
branding_data = self.branding_service.get_company_branding(company_short_name)
|
|
36
|
+
current_lang = request.args.get("lang") or "en"
|
|
37
|
+
|
|
36
38
|
return render_template('signup.html',
|
|
37
39
|
company_short_name=company_short_name,
|
|
38
|
-
branding=branding_data
|
|
40
|
+
branding=branding_data,
|
|
41
|
+
lang=current_lang)
|
|
39
42
|
|
|
40
43
|
def post(self, company_short_name: str):
|
|
41
44
|
try:
|
|
@@ -52,6 +55,9 @@ class SignupView(MethodView):
|
|
|
52
55
|
password = request.form.get('password')
|
|
53
56
|
confirm_password = request.form.get('confirm_password')
|
|
54
57
|
|
|
58
|
+
# get the language from the form, then query
|
|
59
|
+
current_lang = request.form.get("lang") or request.args.get("lang")
|
|
60
|
+
|
|
55
61
|
# create verification token and url for verification
|
|
56
62
|
token = self.serializer.dumps(email, salt='email-confirm')
|
|
57
63
|
verification_url = url_for('verify_account',
|
|
@@ -71,6 +77,7 @@ class SignupView(MethodView):
|
|
|
71
77
|
'signup.html',
|
|
72
78
|
company_short_name=company_short_name,
|
|
73
79
|
branding=branding_data,
|
|
80
|
+
lang=current_lang,
|
|
74
81
|
form_data={
|
|
75
82
|
"first_name": first_name,
|
|
76
83
|
"last_name": last_name,
|
|
@@ -80,7 +87,7 @@ class SignupView(MethodView):
|
|
|
80
87
|
}), 400
|
|
81
88
|
|
|
82
89
|
flash(response["message"], 'success')
|
|
83
|
-
return redirect(url_for('home', company_short_name=company_short_name))
|
|
90
|
+
return redirect(url_for('home', company_short_name=company_short_name, lang=current_lang))
|
|
84
91
|
|
|
85
92
|
except Exception as e:
|
|
86
93
|
message = self.i18n_service.t('errors.templates.processing_error', error=str(e))
|
|
@@ -88,5 +95,6 @@ class SignupView(MethodView):
|
|
|
88
95
|
"error.html",
|
|
89
96
|
company_short_name=company_short_name,
|
|
90
97
|
branding=branding_data,
|
|
91
|
-
message=message
|
|
98
|
+
message=message,
|
|
99
|
+
lang=current_lang
|
|
92
100
|
), 500
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from flask import render_template
|
|
2
|
+
from flask.views import MethodView
|
|
3
|
+
from injector import inject
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StaticPageView(MethodView):
|
|
7
|
+
"""
|
|
8
|
+
View genérica para servir páginas estáticas simples (sin lógica de negocio compleja).
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@inject
|
|
12
|
+
def __init__(self):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
def get(self, page_name: str):
|
|
16
|
+
# Mapeo seguro de nombres de página a plantillas
|
|
17
|
+
# Esto evita que se intente cargar cualquier archivo arbitrario
|
|
18
|
+
valid_pages = {
|
|
19
|
+
'foundation': 'docs/foundation.html',
|
|
20
|
+
'mini_project': 'docs/mini_project.html'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if page_name not in valid_pages:
|
|
24
|
+
# Si la página no existe, podríamos retornar un 404 o redirigir al index
|
|
25
|
+
return render_template('error.html', message=f"Página no encontrada: {page_name}"), 404
|
|
26
|
+
|
|
27
|
+
return render_template(valid_pages[page_name])
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from flask.views import MethodView
|
|
2
|
+
from flask import jsonify
|
|
3
|
+
from injector import inject
|
|
4
|
+
from iatoolkit.services.auth_service import AuthService
|
|
5
|
+
from iatoolkit.services.profile_service import ProfileService
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UsersApiView(MethodView):
|
|
10
|
+
"""
|
|
11
|
+
list company users and their roles
|
|
12
|
+
"""
|
|
13
|
+
@inject
|
|
14
|
+
def __init__(self,
|
|
15
|
+
auth_service: AuthService,
|
|
16
|
+
profile_service: ProfileService):
|
|
17
|
+
self.auth_service = auth_service
|
|
18
|
+
self.profile_service = profile_service
|
|
19
|
+
|
|
20
|
+
def get(self, company_short_name: str):
|
|
21
|
+
try:
|
|
22
|
+
auth_result = self.auth_service.verify(anonymous=True)
|
|
23
|
+
if not auth_result.get("success"):
|
|
24
|
+
return jsonify(auth_result), auth_result.get("status_code", 401)
|
|
25
|
+
|
|
26
|
+
# get users of the company
|
|
27
|
+
users = self.profile_service.get_company_users(company_short_name)
|
|
28
|
+
|
|
29
|
+
return jsonify(users), 200
|
|
30
|
+
|
|
31
|
+
except Exception as e:
|
|
32
|
+
logging.exception(f"Error fetching users for {company_short_name}: {e}")
|
|
33
|
+
return jsonify({"error": "Unexpected error", "details": str(e)}), 500
|
|
@@ -22,7 +22,7 @@ class VerifyAccountView(MethodView):
|
|
|
22
22
|
self.profile_service = profile_service
|
|
23
23
|
self.branding_service = branding_service
|
|
24
24
|
self.i18n_service = i18n_service
|
|
25
|
-
self.serializer = URLSafeTimedSerializer(os.getenv("
|
|
25
|
+
self.serializer = URLSafeTimedSerializer(os.getenv("IATOOLKIT_SECRET_KEY"))
|
|
26
26
|
|
|
27
27
|
def get(self, company_short_name: str, token: str):
|
|
28
28
|
try:
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iatoolkit
|
|
3
|
+
Version: 1.4.2
|
|
4
|
+
Summary: IAToolkit
|
|
5
|
+
Author: Fernando Libedinsky
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE_COMMUNITY.md
|
|
11
|
+
Requires-Dist: bcrypt==4.2.1
|
|
12
|
+
Requires-Dist: boto3==1.36.22
|
|
13
|
+
Requires-Dist: botocore==1.36.22
|
|
14
|
+
Requires-Dist: build==1.2.2.post1
|
|
15
|
+
Requires-Dist: click==8.1.8
|
|
16
|
+
Requires-Dist: cryptography==44.0.3
|
|
17
|
+
Requires-Dist: Flask==3.1.0
|
|
18
|
+
Requires-Dist: Flask-Bcrypt==1.0.1
|
|
19
|
+
Requires-Dist: flask-cors==6.0.0
|
|
20
|
+
Requires-Dist: Flask-Injector==0.15.0
|
|
21
|
+
Requires-Dist: Flask-Session==0.8.0
|
|
22
|
+
Requires-Dist: flatbuffers==24.3.25
|
|
23
|
+
Requires-Dist: google-ai-generativelanguage==0.6.15
|
|
24
|
+
Requires-Dist: google-api-core==2.24.1
|
|
25
|
+
Requires-Dist: google-api-python-client==2.161.0
|
|
26
|
+
Requires-Dist: google-auth==2.37.0
|
|
27
|
+
Requires-Dist: google-auth-httplib2==0.2.0
|
|
28
|
+
Requires-Dist: google-auth-oauthlib==1.2.1
|
|
29
|
+
Requires-Dist: google-cloud-core==2.4.1
|
|
30
|
+
Requires-Dist: google-cloud-storage==3.0.0
|
|
31
|
+
Requires-Dist: google-crc32c==1.6.0
|
|
32
|
+
Requires-Dist: google-generativeai==0.8.5
|
|
33
|
+
Requires-Dist: google-resumable-media==2.7.2
|
|
34
|
+
Requires-Dist: googleapis-common-protos==1.66.0
|
|
35
|
+
Requires-Dist: gunicorn==23.0.0
|
|
36
|
+
Requires-Dist: h11==0.14.0
|
|
37
|
+
Requires-Dist: httpcore==1.0.7
|
|
38
|
+
Requires-Dist: httplib2==0.22.0
|
|
39
|
+
Requires-Dist: httptools==0.6.4
|
|
40
|
+
Requires-Dist: httpx==0.28.0
|
|
41
|
+
Requires-Dist: httpx-sse==0.4.0
|
|
42
|
+
Requires-Dist: huggingface-hub==0.31.4
|
|
43
|
+
Requires-Dist: humanfriendly==10.0
|
|
44
|
+
Requires-Dist: idna==3.10
|
|
45
|
+
Requires-Dist: injector==0.22.0
|
|
46
|
+
Requires-Dist: Jinja2==3.1.5
|
|
47
|
+
Requires-Dist: langchain==0.3.19
|
|
48
|
+
Requires-Dist: langchain-core==0.3.35
|
|
49
|
+
Requires-Dist: langchain-text-splitters==0.3.6
|
|
50
|
+
Requires-Dist: markdown2==2.5.3
|
|
51
|
+
Requires-Dist: openai==2.8.1
|
|
52
|
+
Requires-Dist: openpyxl==3.1.5
|
|
53
|
+
Requires-Dist: pandas==2.3.1
|
|
54
|
+
Requires-Dist: pgvector==0.3.6
|
|
55
|
+
Requires-Dist: pillow==11.0.0
|
|
56
|
+
Requires-Dist: psutil==7.0.0
|
|
57
|
+
Requires-Dist: psycopg2-binary==2.9.10
|
|
58
|
+
Requires-Dist: PyJWT==2.10.1
|
|
59
|
+
Requires-Dist: PyMuPDF==1.25.0
|
|
60
|
+
Requires-Dist: python-dotenv==1.0.1
|
|
61
|
+
Requires-Dist: pytest==8.3.4
|
|
62
|
+
Requires-Dist: pytest-cov==5.0.0
|
|
63
|
+
Requires-Dist: pytest-mock==3.14.0
|
|
64
|
+
Requires-Dist: python-dateutil==2.9.0.post0
|
|
65
|
+
Requires-Dist: python-docx==1.1.2
|
|
66
|
+
Requires-Dist: pytesseract==0.3.13
|
|
67
|
+
Requires-Dist: pytz==2025.2
|
|
68
|
+
Requires-Dist: PyYAML==6.0.2
|
|
69
|
+
Requires-Dist: redis==5.2.1
|
|
70
|
+
Requires-Dist: regex==2024.11.6
|
|
71
|
+
Requires-Dist: requests==2.32.3
|
|
72
|
+
Requires-Dist: requests-oauthlib==2.0.0
|
|
73
|
+
Requires-Dist: requests-toolbelt==1.0.0
|
|
74
|
+
Requires-Dist: s3transfer==0.11.2
|
|
75
|
+
Requires-Dist: sib-api-v3-sdk==7.6.0
|
|
76
|
+
Requires-Dist: SQLAlchemy==2.0.36
|
|
77
|
+
Requires-Dist: tiktoken==0.8.0
|
|
78
|
+
Requires-Dist: tokenizers==0.21.0
|
|
79
|
+
Requires-Dist: websocket-client==1.8.0
|
|
80
|
+
Requires-Dist: websockets==14.1
|
|
81
|
+
Requires-Dist: Werkzeug==3.1.3
|
|
82
|
+
Requires-Dist: pyjwt[crypto]>=2.8.0
|
|
83
|
+
Dynamic: license-file
|
|
84
|
+
|
|
85
|
+
# 🧠 IAToolkit — Open-Source Framework for Real-World AI Assistants
|
|
86
|
+
|
|
87
|
+
Build private, production-grade AI assistants that run entirely inside your environment and speak the language of your business.
|
|
88
|
+
|
|
89
|
+
IAToolkit is not a demo wrapper or a prompt playground — it is a **full architecture** for implementing intelligent systems that combine LLMs, SQL data, internal documents, tools, workflows, and multi-tenant business logic.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🚀 Why IAToolkit?
|
|
94
|
+
|
|
95
|
+
Modern AI development is fragmented: LangChain handles chains, LlamaIndex handles documents,
|
|
96
|
+
your backend handles SQL, your frontend handles chats, and your devs glue everything together.
|
|
97
|
+
|
|
98
|
+
**IAToolkit brings all of this into one unified, production-ready framework.**
|
|
99
|
+
|
|
100
|
+
It focuses on:
|
|
101
|
+
|
|
102
|
+
- **real-world data** (SQL + documents)
|
|
103
|
+
- **real workflows** (LLM tools + python services)
|
|
104
|
+
- **real multi-tenant architecture** (1 company → many companies)
|
|
105
|
+
- **real constraints** (security, reproducibility, governance)
|
|
106
|
+
- **real deployment** (your servers, your infrastructure)
|
|
107
|
+
|
|
108
|
+
IAToolkit lets you build the assistant that *your* organization needs — not a generic chatbot.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🧩 Architecture in a Nutshell
|
|
113
|
+
|
|
114
|
+
IAToolkit is a structured, layered framework:
|
|
115
|
+
|
|
116
|
+
Interfaces (Web & API)
|
|
117
|
+
↓
|
|
118
|
+
Intelligence Layer (prompts, tools, SQL orchestration, RAG)
|
|
119
|
+
↓
|
|
120
|
+
Execution Layer (services, workflows, validation)
|
|
121
|
+
↓
|
|
122
|
+
Data Access (SQLAlchemy, connectors)
|
|
123
|
+
↓
|
|
124
|
+
Company Modules (company.yaml + custom tools)
|
|
125
|
+
|
|
126
|
+
### ✔ Interfaces
|
|
127
|
+
Chat UI, REST API, auth, sessions, JSON/HTML responses.
|
|
128
|
+
|
|
129
|
+
### ✔ Intelligence Layer
|
|
130
|
+
Core logic: prompt rendering, SQL orchestration, RAG, LLM tool dispatching.
|
|
131
|
+
|
|
132
|
+
### ✔ Execution Layer
|
|
133
|
+
Python services that implement real workflows: querying data, generating reports, retrieving documents, executing business logic.
|
|
134
|
+
|
|
135
|
+
### ✔ Data Access
|
|
136
|
+
A clean repository pattern using SQLAlchemy.
|
|
137
|
+
|
|
138
|
+
### ✔ Company Modules
|
|
139
|
+
Each company has:
|
|
140
|
+
|
|
141
|
+
- its own `company.yaml`
|
|
142
|
+
- its own prompts
|
|
143
|
+
- its own tools
|
|
144
|
+
- its own services
|
|
145
|
+
- its own vector store & SQL context
|
|
146
|
+
|
|
147
|
+
This modularity allows **true multi-tenancy**.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 🔌 Connect to Anything
|
|
152
|
+
|
|
153
|
+
IAToolkit integrates naturally with:
|
|
154
|
+
|
|
155
|
+
- **SQL databases** (PostgreSQL, MySQL, SQL Server, etc.)
|
|
156
|
+
- **Document retrieval** (PDF, text, embeddings)
|
|
157
|
+
- **External APIs**
|
|
158
|
+
- **Internal microservices**
|
|
159
|
+
- **Custom Python tools**
|
|
160
|
+
|
|
161
|
+
It also includes a **production-grade RAG pipeline**, combining:
|
|
162
|
+
|
|
163
|
+
- embeddings
|
|
164
|
+
- chunking
|
|
165
|
+
- hybrid search
|
|
166
|
+
- SQL queries + document retrieval
|
|
167
|
+
- tool execution
|
|
168
|
+
|
|
169
|
+
Everything orchestrated through the Intelligence Layer.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 🏢 Multi-Tenant Architecture
|
|
174
|
+
|
|
175
|
+
A single installation of IAToolkit can power assistants for multiple companies, departments, or customers.
|
|
176
|
+
```text
|
|
177
|
+
companies/
|
|
178
|
+
company_a
|
|
179
|
+
company_b
|
|
180
|
+
company_c
|
|
181
|
+
```
|
|
182
|
+
Each Company is fully isolated:
|
|
183
|
+
|
|
184
|
+
- prompts
|
|
185
|
+
- tools
|
|
186
|
+
- credentials
|
|
187
|
+
- documents
|
|
188
|
+
- SQL contexts
|
|
189
|
+
- business rules
|
|
190
|
+
|
|
191
|
+
This makes IAToolkit ideal for SaaS products, agencies, consultancies, and organizations with multiple business units.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 🆓 Community Edition vs Enterprise Edition
|
|
196
|
+
|
|
197
|
+
IAToolkit follows a modern **open-core** model:
|
|
198
|
+
|
|
199
|
+
### 🟦 Community Edition (MIT License)
|
|
200
|
+
- Full Open-Source Core
|
|
201
|
+
- SQL + Basic RAG
|
|
202
|
+
- One Company
|
|
203
|
+
- Custom Python tools
|
|
204
|
+
- Self-managed deployment
|
|
205
|
+
|
|
206
|
+
Perfect for developers, small teams, single-business use cases, and experimentation.
|
|
207
|
+
|
|
208
|
+
### 🟥 Enterprise Edition (Commercial License)
|
|
209
|
+
- Unlimited Companies (multi-tenant)
|
|
210
|
+
- Payment services integration
|
|
211
|
+
- Enterprise Agent Workflows
|
|
212
|
+
- SSO integration
|
|
213
|
+
- Priority support & continuous updates
|
|
214
|
+
- Activation via **License Key**
|
|
215
|
+
|
|
216
|
+
👉 Licensing information:
|
|
217
|
+
- [Community Edition (MIT)](LICENSE_COMMUNITY.md)
|
|
218
|
+
- [Enterprise License](ENTERPRISE_LICENSE.md)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 🧩 Who Is IAToolkit For?
|
|
223
|
+
|
|
224
|
+
- Companies building internal “ChatGPT for the business”
|
|
225
|
+
- SaaS products adding AI assistants for multiple customers
|
|
226
|
+
- AI teams that need reproducible prompts and controlled tools
|
|
227
|
+
- Developers who want real workflows, not toy demos
|
|
228
|
+
- Organizations requiring privacy, security, and self-hosting
|
|
229
|
+
- Teams working with SQL-heavy business logic
|
|
230
|
+
- Consultancies deploying AI for multiple clients
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## ⭐ Key Differentiators
|
|
235
|
+
|
|
236
|
+
- prioritizes **architecture-first design**, not chains or wrappers
|
|
237
|
+
- supports **multi-company** out of the box
|
|
238
|
+
- integrates **SQL, RAG, and tools** into a single intelligence layer
|
|
239
|
+
- keeps **business logic isolated** inside Company modules
|
|
240
|
+
- runs entirely **on your own infrastructure**
|
|
241
|
+
- ships with a **full web chat**, and API.
|
|
242
|
+
- is built for **production**, not prototypes
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 📚 Documentation
|
|
247
|
+
|
|
248
|
+
- 🚀 **[Quickstart](docs/quickstart.md)** – Set up your environment and run the project
|
|
249
|
+
- ☁️ **[Deployment Guide](docs/deployment_guide.md)** – Production deployment instructions
|
|
250
|
+
- 🏗️ **[Companies & Components](docs/companies_and_components.md)** – how Company modules work
|
|
251
|
+
- 🧠 **[Programming Guide](docs/programming_guide.md)** – services, intelligence layer, dispatching
|
|
252
|
+
- 🗃️ **[Database Guide](docs/database_guide.md)** – internal schema overview
|
|
253
|
+
- 🌱 **[Foundation Article](https://iatoolkit.com/pages/foundation)** – the “Why” behind the architecture
|
|
254
|
+
- 📘 **[Mini-Project (3 months)](https://iatoolkit.com/pages/mini_project)** – how to deploy a corporate AI assistant
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## 🤝 Contributing
|
|
260
|
+
|
|
261
|
+
IAToolkit is open-source and community-friendly.
|
|
262
|
+
PRs, issues, ideas, and feedback are always welcome.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## ⭐ Support the Project
|
|
267
|
+
|
|
268
|
+
If you find IAToolkit useful, please **star the GitHub repo** — it helps visibility and adoption.
|