fitini 0.1.0__tar.gz
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.
- fitini-0.1.0/LICENSE +201 -0
- fitini-0.1.0/NOTICE +4 -0
- fitini-0.1.0/PKG-INFO +118 -0
- fitini-0.1.0/README.md +84 -0
- fitini-0.1.0/fitini/__init__.py +1 -0
- fitini-0.1.0/fitini/audio_transcriber.py +167 -0
- fitini-0.1.0/fitini/auth.py +60 -0
- fitini-0.1.0/fitini/cli.py +109 -0
- fitini-0.1.0/fitini/config.json +30 -0
- fitini-0.1.0/fitini/db.py +106 -0
- fitini-0.1.0/fitini/doc_ingest.py +98 -0
- fitini-0.1.0/fitini/dossier_analyze.py +89 -0
- fitini-0.1.0/fitini/dossier_export.py +166 -0
- fitini-0.1.0/fitini/dossiers.py +116 -0
- fitini-0.1.0/fitini/fitini_core.py +371 -0
- fitini-0.1.0/fitini/packs.py +82 -0
- fitini-0.1.0/fitini/profiles/cybersecurity/cti.json +144 -0
- fitini-0.1.0/fitini/profiles/healthcare/consultation.json +219 -0
- fitini-0.1.0/fitini/profiles/healthcare/pharmacovigilance.json +114 -0
- fitini-0.1.0/fitini/profiles/investigation/ediscovery.json +92 -0
- fitini-0.1.0/fitini/profiles/investigation/intercept.json +53 -0
- fitini-0.1.0/fitini/profiles/investigation/social.json +172 -0
- fitini-0.1.0/fitini/server.py +542 -0
- fitini-0.1.0/fitini/static/fitini_logo.png +0 -0
- fitini-0.1.0/fitini/static/index.html +915 -0
- fitini-0.1.0/fitini/web_collect.py +122 -0
- fitini-0.1.0/fitini.egg-info/PKG-INFO +118 -0
- fitini-0.1.0/fitini.egg-info/SOURCES.txt +32 -0
- fitini-0.1.0/fitini.egg-info/dependency_links.txt +1 -0
- fitini-0.1.0/fitini.egg-info/entry_points.txt +2 -0
- fitini-0.1.0/fitini.egg-info/requires.txt +25 -0
- fitini-0.1.0/fitini.egg-info/top_level.txt +1 -0
- fitini-0.1.0/pyproject.toml +37 -0
- fitini-0.1.0/setup.cfg +4 -0
fitini-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 VD Info
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
fitini-0.1.0/NOTICE
ADDED
fitini-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fitini
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fitini — du cas au dossier : moteur d'aide à l'investigation, hors-ligne et déterministe.
|
|
5
|
+
Author: VD Info
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: investigation,osint,transcription,dossier,offline
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Requires-Dist: fastapi>=0.115
|
|
13
|
+
Requires-Dist: uvicorn[standard]>=0.30
|
|
14
|
+
Requires-Dist: websockets>=13
|
|
15
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
16
|
+
Requires-Dist: pymupdf>=1.24
|
|
17
|
+
Requires-Dist: python-docx>=1.1
|
|
18
|
+
Requires-Dist: fpdf2>=2.7
|
|
19
|
+
Provides-Extra: audio
|
|
20
|
+
Requires-Dist: faster-whisper>=1.0; extra == "audio"
|
|
21
|
+
Requires-Dist: sounddevice>=0.5; extra == "audio"
|
|
22
|
+
Requires-Dist: numpy>=1.26; extra == "audio"
|
|
23
|
+
Provides-Extra: ocr
|
|
24
|
+
Requires-Dist: rapidocr-onnxruntime>=1.3; extra == "ocr"
|
|
25
|
+
Provides-Extra: ner
|
|
26
|
+
Requires-Dist: spacy>=3.7; extra == "ner"
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: faster-whisper>=1.0; extra == "all"
|
|
29
|
+
Requires-Dist: sounddevice>=0.5; extra == "all"
|
|
30
|
+
Requires-Dist: numpy>=1.26; extra == "all"
|
|
31
|
+
Requires-Dist: rapidocr-onnxruntime>=1.3; extra == "all"
|
|
32
|
+
Requires-Dist: spacy>=3.7; extra == "all"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="fitini/static/fitini_logo.png" alt="Fitini" width="180">
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<h1 align="center">Fitini — Les murs ont des oreilles</h1>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Fitini analyse des **sources texte et audio** (les fichiers de l'utilisateur, ou des sources web qu'il verse lui-même) pour mener une investigation : il extrait les entités d'intérêt, les corrèle, bâtit un graphe et une chronologie, flague les signaux, monte un **dossier d'enquête** et l'exporte — le tout **tracé à la source**.
|
|
43
|
+
|
|
44
|
+
Trois domaines (packs de connaissances) : **cybersécurité (CTI)**, **justice / Journalisme**, **santé / biomédical / pharmacovigilance**.
|
|
45
|
+
|
|
46
|
+
## Fonctions clés
|
|
47
|
+
- **INTERCEPT** — écoute micro en direct (FR/EN auto, transcription faster-whisper, VAD énergétique), flags et flèches en temps réel, modal d'alerte.
|
|
48
|
+
- **ANALYSE** — dépôt de fichiers (PDF / DOCX / images OCR / audio) → extraction → corrélation → rapport.
|
|
49
|
+
- **DOSSIER** — monte un dossier autour d'un sujet : **recherche web** (opt-in) → résultats **cochables** → téléchargement dans le dossier → **juxtaposition avant/maintenant** datée et sourcée → **export Markdown / PDF**.
|
|
50
|
+
- **Rapport déterministe** — ce qui ressort, qui est lié à qui, chronologie, flags, passages-clés **sourcés**. Aucun jugement émis : l'outil surface et aligne, **l'humain juge**.
|
|
51
|
+
|
|
52
|
+
## Extraction ouverte
|
|
53
|
+
- **Sélecteurs génériques** (sans lexique) : e-mail, téléphone, IP, URL, @pseudo, montants/FCFA, dates, coordonnées GPS, CVE, IBAN.
|
|
54
|
+
- **NER spaCy** (optionnelle) : PERSON / ORG / LIEU / DATE / MONEY, même pour des entités jamais listées. Repli propre si le modèle est absent.
|
|
55
|
+
- **Watchlist utilisateur** : le sujet / les sélecteurs saisis pilotent flags, priorité et alertes.
|
|
56
|
+
- Les packs de domaine (`profiles/*.json`) apportent une connaissance métier **optionnelle**, jamais la condition d'entrée.
|
|
57
|
+
|
|
58
|
+
## Flag (par type, puis par sujet)
|
|
59
|
+
Toute **entité détectée** (personne, organisation, lieu, montant, GPS, IBAN, CVE, arme/violence…) est flaguée automatiquement → flèche vers la matrice. Le **sujet déclaré** (watchlist) ajoute une couche de **priorité** et déclenche le **modal d'alerte URGENT**.
|
|
60
|
+
|
|
61
|
+
## Architecture
|
|
62
|
+
| Fichier | Rôle |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `fitini_core.py` | moteur : extraction (sélecteurs + lexique + NER) → corrélation → hypothèses/lock → alertes → timeline |
|
|
65
|
+
| `packs.py` | charge et fusionne les packs de domaine sélectionnés |
|
|
66
|
+
| `server.py` | FastAPI : auth, WebSocket d'analyse, sessions, **dossiers**, **recherche web**, **export** |
|
|
67
|
+
| `cli.py` | commande `fitini` : `serve` (interface) et `analyze` (ligne de commande) |
|
|
68
|
+
| `audio_transcriber.py` | transcription micro / fichier (faster-whisper, VAD énergétique, hors boucle asyncio) |
|
|
69
|
+
| `doc_ingest.py` | extraction de texte PDF (PyMuPDF) / DOCX / images (OCR RapidOCR) |
|
|
70
|
+
| `dossiers.py` | store local des dossiers d'enquête (fichiers, hors-ligne) |
|
|
71
|
+
| `web_collect.py` | collecte web **opt-in** (Exa / Tavily) — presse, archives |
|
|
72
|
+
| `dossier_analyze.py` | juxtaposition avant/maintenant + entités sur les sources d'un dossier |
|
|
73
|
+
| `dossier_export.py` | export d'un dossier en Markdown / PDF |
|
|
74
|
+
| `db.py` | persistance SQLite (sessions, réglages) |
|
|
75
|
+
| `auth.py` | gate par token (démo-grade — à remplacer en production) |
|
|
76
|
+
| `static/index.html` | interface : INTERCEPT · ANALYSE · REPORT · DOSSIER · ARCHIVE · CONFIG |
|
|
77
|
+
| `profiles/*.json` | packs de connaissances par domaine |
|
|
78
|
+
|
|
79
|
+
## Structure du projet
|
|
80
|
+
```
|
|
81
|
+
Fitini/
|
|
82
|
+
├── fitini/ # package installable (pip)
|
|
83
|
+
│ ├── server.py # FastAPI — point d'entrée : fitini.server:app
|
|
84
|
+
│ ├── cli.py # commande `fitini` (serve / analyze)
|
|
85
|
+
│ ├── fitini_core.py # moteur ; + packs, dossiers, web_collect, dossier_analyze/export, db, auth…
|
|
86
|
+
│ ├── static/ # interface web + logo (servis par le serveur)
|
|
87
|
+
│ ├── profiles/ # packs de domaine (cybersécurité / investigation / santé)
|
|
88
|
+
│ └── config.json # auth, pipeline, réglages par défaut
|
|
89
|
+
├── pyproject.toml # métadonnées + dépendances (installable)
|
|
90
|
+
├── requirements.txt
|
|
91
|
+
├── LICENSE · NOTICE
|
|
92
|
+
└── README.md
|
|
93
|
+
```
|
|
94
|
+
Données d'exécution créées dans le dossier courant, non versionnées : `uploads/`, `dossiers/`, `fitini.db`.
|
|
95
|
+
|
|
96
|
+
## Lancer
|
|
97
|
+
```bash
|
|
98
|
+
# Installation (depuis les sources ; à terme : pip install fitini)
|
|
99
|
+
pip install .
|
|
100
|
+
# extras optionnels : audio (micro), OCR, NER
|
|
101
|
+
pip install ".[audio,ocr,ner]"
|
|
102
|
+
|
|
103
|
+
# Interface web
|
|
104
|
+
fitini serve --open # ouvre http://127.0.0.1:8000
|
|
105
|
+
# (dev : uvicorn fitini.server:app --reload)
|
|
106
|
+
|
|
107
|
+
# Ligne de commande, sans interface
|
|
108
|
+
fitini analyze mon_dossier/ --subject "nom, mot-clé" --format md --out dossier.md
|
|
109
|
+
```
|
|
110
|
+
Recherche web (optionnelle, une clé suffit) :
|
|
111
|
+
```bash
|
|
112
|
+
FITINI_WEB=1 EXA_API_KEY=... fitini serve
|
|
113
|
+
# ou TAVILY_API_KEY=...
|
|
114
|
+
```
|
|
115
|
+
Les **modèles** (Whisper, OCR RapidOCR, spaCy) ne sont **pas inclus** dans le dépôt : ils sont téléchargés / servis côté serveur. Le code reste utilisable tel quel.
|
|
116
|
+
|
|
117
|
+
## Auteur & licence
|
|
118
|
+
Développé par **The Day Info**. Open source sous licence **Apache-2.0** (voir [`LICENSE`](LICENSE) et [`NOTICE`](NOTICE)) — libre de télécharger, utiliser, modifier et redistribuer, avec clause de brevet.
|
fitini-0.1.0/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="fitini/static/fitini_logo.png" alt="Fitini" width="180">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Fitini — Les murs ont des oreilles</h1>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Fitini analyse des **sources texte et audio** (les fichiers de l'utilisateur, ou des sources web qu'il verse lui-même) pour mener une investigation : il extrait les entités d'intérêt, les corrèle, bâtit un graphe et une chronologie, flague les signaux, monte un **dossier d'enquête** et l'exporte — le tout **tracé à la source**.
|
|
9
|
+
|
|
10
|
+
Trois domaines (packs de connaissances) : **cybersécurité (CTI)**, **justice / Journalisme**, **santé / biomédical / pharmacovigilance**.
|
|
11
|
+
|
|
12
|
+
## Fonctions clés
|
|
13
|
+
- **INTERCEPT** — écoute micro en direct (FR/EN auto, transcription faster-whisper, VAD énergétique), flags et flèches en temps réel, modal d'alerte.
|
|
14
|
+
- **ANALYSE** — dépôt de fichiers (PDF / DOCX / images OCR / audio) → extraction → corrélation → rapport.
|
|
15
|
+
- **DOSSIER** — monte un dossier autour d'un sujet : **recherche web** (opt-in) → résultats **cochables** → téléchargement dans le dossier → **juxtaposition avant/maintenant** datée et sourcée → **export Markdown / PDF**.
|
|
16
|
+
- **Rapport déterministe** — ce qui ressort, qui est lié à qui, chronologie, flags, passages-clés **sourcés**. Aucun jugement émis : l'outil surface et aligne, **l'humain juge**.
|
|
17
|
+
|
|
18
|
+
## Extraction ouverte
|
|
19
|
+
- **Sélecteurs génériques** (sans lexique) : e-mail, téléphone, IP, URL, @pseudo, montants/FCFA, dates, coordonnées GPS, CVE, IBAN.
|
|
20
|
+
- **NER spaCy** (optionnelle) : PERSON / ORG / LIEU / DATE / MONEY, même pour des entités jamais listées. Repli propre si le modèle est absent.
|
|
21
|
+
- **Watchlist utilisateur** : le sujet / les sélecteurs saisis pilotent flags, priorité et alertes.
|
|
22
|
+
- Les packs de domaine (`profiles/*.json`) apportent une connaissance métier **optionnelle**, jamais la condition d'entrée.
|
|
23
|
+
|
|
24
|
+
## Flag (par type, puis par sujet)
|
|
25
|
+
Toute **entité détectée** (personne, organisation, lieu, montant, GPS, IBAN, CVE, arme/violence…) est flaguée automatiquement → flèche vers la matrice. Le **sujet déclaré** (watchlist) ajoute une couche de **priorité** et déclenche le **modal d'alerte URGENT**.
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
| Fichier | Rôle |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `fitini_core.py` | moteur : extraction (sélecteurs + lexique + NER) → corrélation → hypothèses/lock → alertes → timeline |
|
|
31
|
+
| `packs.py` | charge et fusionne les packs de domaine sélectionnés |
|
|
32
|
+
| `server.py` | FastAPI : auth, WebSocket d'analyse, sessions, **dossiers**, **recherche web**, **export** |
|
|
33
|
+
| `cli.py` | commande `fitini` : `serve` (interface) et `analyze` (ligne de commande) |
|
|
34
|
+
| `audio_transcriber.py` | transcription micro / fichier (faster-whisper, VAD énergétique, hors boucle asyncio) |
|
|
35
|
+
| `doc_ingest.py` | extraction de texte PDF (PyMuPDF) / DOCX / images (OCR RapidOCR) |
|
|
36
|
+
| `dossiers.py` | store local des dossiers d'enquête (fichiers, hors-ligne) |
|
|
37
|
+
| `web_collect.py` | collecte web **opt-in** (Exa / Tavily) — presse, archives |
|
|
38
|
+
| `dossier_analyze.py` | juxtaposition avant/maintenant + entités sur les sources d'un dossier |
|
|
39
|
+
| `dossier_export.py` | export d'un dossier en Markdown / PDF |
|
|
40
|
+
| `db.py` | persistance SQLite (sessions, réglages) |
|
|
41
|
+
| `auth.py` | gate par token (démo-grade — à remplacer en production) |
|
|
42
|
+
| `static/index.html` | interface : INTERCEPT · ANALYSE · REPORT · DOSSIER · ARCHIVE · CONFIG |
|
|
43
|
+
| `profiles/*.json` | packs de connaissances par domaine |
|
|
44
|
+
|
|
45
|
+
## Structure du projet
|
|
46
|
+
```
|
|
47
|
+
Fitini/
|
|
48
|
+
├── fitini/ # package installable (pip)
|
|
49
|
+
│ ├── server.py # FastAPI — point d'entrée : fitini.server:app
|
|
50
|
+
│ ├── cli.py # commande `fitini` (serve / analyze)
|
|
51
|
+
│ ├── fitini_core.py # moteur ; + packs, dossiers, web_collect, dossier_analyze/export, db, auth…
|
|
52
|
+
│ ├── static/ # interface web + logo (servis par le serveur)
|
|
53
|
+
│ ├── profiles/ # packs de domaine (cybersécurité / investigation / santé)
|
|
54
|
+
│ └── config.json # auth, pipeline, réglages par défaut
|
|
55
|
+
├── pyproject.toml # métadonnées + dépendances (installable)
|
|
56
|
+
├── requirements.txt
|
|
57
|
+
├── LICENSE · NOTICE
|
|
58
|
+
└── README.md
|
|
59
|
+
```
|
|
60
|
+
Données d'exécution créées dans le dossier courant, non versionnées : `uploads/`, `dossiers/`, `fitini.db`.
|
|
61
|
+
|
|
62
|
+
## Lancer
|
|
63
|
+
```bash
|
|
64
|
+
# Installation (depuis les sources ; à terme : pip install fitini)
|
|
65
|
+
pip install .
|
|
66
|
+
# extras optionnels : audio (micro), OCR, NER
|
|
67
|
+
pip install ".[audio,ocr,ner]"
|
|
68
|
+
|
|
69
|
+
# Interface web
|
|
70
|
+
fitini serve --open # ouvre http://127.0.0.1:8000
|
|
71
|
+
# (dev : uvicorn fitini.server:app --reload)
|
|
72
|
+
|
|
73
|
+
# Ligne de commande, sans interface
|
|
74
|
+
fitini analyze mon_dossier/ --subject "nom, mot-clé" --format md --out dossier.md
|
|
75
|
+
```
|
|
76
|
+
Recherche web (optionnelle, une clé suffit) :
|
|
77
|
+
```bash
|
|
78
|
+
FITINI_WEB=1 EXA_API_KEY=... fitini serve
|
|
79
|
+
# ou TAVILY_API_KEY=...
|
|
80
|
+
```
|
|
81
|
+
Les **modèles** (Whisper, OCR RapidOCR, spaCy) ne sont **pas inclus** dans le dépôt : ils sont téléchargés / servis côté serveur. Le code reste utilisable tel quel.
|
|
82
|
+
|
|
83
|
+
## Auteur & licence
|
|
84
|
+
Développé par **The Day Info**. Open source sous licence **Apache-2.0** (voir [`LICENSE`](LICENSE) et [`NOTICE`](NOTICE)) — libre de télécharger, utiliser, modifier et redistribuer, avec clause de brevet.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Fitini — investigation assistance engine (package)."""
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""
|
|
2
|
+
audio_transcriber.py — audio acquisition + transcription for Fitini Voice Analyzer.
|
|
3
|
+
|
|
4
|
+
Three sources, one async interface (`stream_transcriptions`):
|
|
5
|
+
|
|
6
|
+
* MICROPHONE — sounddevice capture -> energy VAD gating -> faster-whisper.
|
|
7
|
+
* FILE — transcribe a recorded file with faster-whisper.
|
|
8
|
+
|
|
9
|
+
CRITICAL FIX vs. the original spec: VAD and Whisper are synchronous, CPU-heavy
|
|
10
|
+
calls. Running them directly inside the asyncio event loop blocks every WebSocket on the
|
|
11
|
+
server. Here, every model call is dispatched with `asyncio.to_thread(...)` so the event
|
|
12
|
+
loop stays responsive.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
import queue
|
|
19
|
+
import time
|
|
20
|
+
from typing import Any, AsyncGenerator, Dict, Optional
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AudioStreamTranscriber:
|
|
24
|
+
def __init__(self, config: Dict[str, Any], use_microphone: bool = False):
|
|
25
|
+
p = config.get("pipeline", {})
|
|
26
|
+
self.config = config
|
|
27
|
+
self.use_microphone = use_microphone
|
|
28
|
+
self.sample_rate = int(p.get("sample_rate", 16000))
|
|
29
|
+
self.model_size = p.get("model_size", "base.en")
|
|
30
|
+
self.device = p.get("device", "cpu")
|
|
31
|
+
self.compute_type = p.get("compute_type", "int8")
|
|
32
|
+
self.vad_threshold = float(p.get("vad_threshold", 0.5))
|
|
33
|
+
self.energy_threshold = float(p.get("energy_threshold", 0.01))
|
|
34
|
+
self.silence_frames_limit = int(p.get("silence_frames", 18))
|
|
35
|
+
self.chunk_samples = int(p.get("chunk_samples", 512))
|
|
36
|
+
self.sim_interval = float(p.get("simulation_interval_seconds", 1.1))
|
|
37
|
+
self.beam_size = int(p.get("beam_size", 1))
|
|
38
|
+
lang = p.get("language", "auto")
|
|
39
|
+
# None lets faster-whisper auto-detect the language (FR or EN) per source.
|
|
40
|
+
self.language = None if lang in ("", "auto", None) else lang
|
|
41
|
+
|
|
42
|
+
self.audio_queue: "queue.Queue" = queue.Queue()
|
|
43
|
+
self.whisper_model = None
|
|
44
|
+
self.vad_model = None
|
|
45
|
+
|
|
46
|
+
# ------------------------------------------------------------------ #
|
|
47
|
+
def _load_models(self) -> None:
|
|
48
|
+
"""Blocking Whisper load -- always called via asyncio.to_thread (no torch)."""
|
|
49
|
+
from faster_whisper import WhisperModel # type: ignore
|
|
50
|
+
|
|
51
|
+
self.whisper_model = WhisperModel(
|
|
52
|
+
self.model_size, device=self.device, compute_type=self.compute_type
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def _now_ts() -> str:
|
|
57
|
+
return time.strftime("%H:%M:%S")
|
|
58
|
+
|
|
59
|
+
# ------------------------------------------------------------------ #
|
|
60
|
+
async def stream_transcriptions(self) -> AsyncGenerator[Dict[str, str], None]:
|
|
61
|
+
"""Yield {'ts', 'text'} dicts as speech is transcribed (live capture)."""
|
|
62
|
+
async for item in self._stream_microphone():
|
|
63
|
+
yield item
|
|
64
|
+
|
|
65
|
+
# ------------------------------------------------------------------ #
|
|
66
|
+
def _audio_callback(self, indata, frames, time_info, status): # pragma: no cover
|
|
67
|
+
self.audio_queue.put(indata[:, 0].copy())
|
|
68
|
+
|
|
69
|
+
def _reset_segmenter(self) -> None:
|
|
70
|
+
self._speech_buffer: list = []
|
|
71
|
+
self._silence_frames: int = 0
|
|
72
|
+
|
|
73
|
+
async def _ingest_chunk(self, chunk, vad_fn, transcribe_fn):
|
|
74
|
+
"""Feed one audio chunk through the VAD-gated segmenter.
|
|
75
|
+
|
|
76
|
+
`vad_fn(chunk) -> float` and `transcribe_fn(audio) -> str` are injected so this
|
|
77
|
+
state machine can be exercised with real models (mic path) or stubs (tests),
|
|
78
|
+
and both are dispatched OFF the event loop via asyncio.to_thread. Returns a
|
|
79
|
+
transcribed string when a speech segment completes, else None.
|
|
80
|
+
"""
|
|
81
|
+
import numpy as np # type: ignore
|
|
82
|
+
|
|
83
|
+
# VAD inference OFF the event loop.
|
|
84
|
+
speech_prob = await asyncio.to_thread(vad_fn, chunk)
|
|
85
|
+
|
|
86
|
+
if speech_prob > self.vad_threshold:
|
|
87
|
+
self._speech_buffer.append(chunk)
|
|
88
|
+
self._silence_frames = 0
|
|
89
|
+
elif self._speech_buffer:
|
|
90
|
+
self._speech_buffer.append(chunk)
|
|
91
|
+
self._silence_frames += 1
|
|
92
|
+
if self._silence_frames > self.silence_frames_limit:
|
|
93
|
+
full_audio = np.concatenate(self._speech_buffer)
|
|
94
|
+
self._reset_segmenter()
|
|
95
|
+
# Transcription OFF the event loop.
|
|
96
|
+
text = await asyncio.to_thread(transcribe_fn, full_audio)
|
|
97
|
+
return text or None
|
|
98
|
+
return None
|
|
99
|
+
|
|
100
|
+
async def _stream_microphone(self) -> AsyncGenerator[Dict[str, str], None]: # pragma: no cover
|
|
101
|
+
import sounddevice as sd # type: ignore
|
|
102
|
+
import numpy as np # type: ignore
|
|
103
|
+
|
|
104
|
+
if self.whisper_model is None:
|
|
105
|
+
await asyncio.to_thread(self._load_models)
|
|
106
|
+
|
|
107
|
+
self._reset_segmenter()
|
|
108
|
+
|
|
109
|
+
def vad_fn(chunk):
|
|
110
|
+
# Energy-based VAD (RMS) -- deterministic, offline, no torch/Silero.
|
|
111
|
+
rms = float(np.sqrt(np.mean(np.square(chunk)))) if len(chunk) else 0.0
|
|
112
|
+
return 1.0 if rms >= self.energy_threshold else 0.0
|
|
113
|
+
|
|
114
|
+
with sd.InputStream(
|
|
115
|
+
samplerate=self.sample_rate,
|
|
116
|
+
channels=1,
|
|
117
|
+
dtype="float32",
|
|
118
|
+
blocksize=self.chunk_samples,
|
|
119
|
+
callback=self._audio_callback,
|
|
120
|
+
):
|
|
121
|
+
while True:
|
|
122
|
+
await asyncio.sleep(0.01)
|
|
123
|
+
while not self.audio_queue.empty():
|
|
124
|
+
chunk = self.audio_queue.get_nowait()
|
|
125
|
+
text = await self._ingest_chunk(chunk, vad_fn, self._transcribe_array)
|
|
126
|
+
if text:
|
|
127
|
+
yield {"ts": self._now_ts(), "text": text}
|
|
128
|
+
|
|
129
|
+
# ------------------------------------------------------------------ #
|
|
130
|
+
def _transcribe_array(self, audio) -> str: # pragma: no cover
|
|
131
|
+
"""Blocking Whisper call — always dispatched via asyncio.to_thread."""
|
|
132
|
+
segments, _ = self.whisper_model.transcribe(
|
|
133
|
+
audio, beam_size=self.beam_size, language=self.language, vad_filter=False
|
|
134
|
+
)
|
|
135
|
+
return " ".join(seg.text.strip() for seg in segments).strip()
|
|
136
|
+
|
|
137
|
+
async def transcribe_file(self, path: str) -> AsyncGenerator[Dict[str, str], None]:
|
|
138
|
+
"""Transcribe a recorded file, yielding each segment as it is decoded."""
|
|
139
|
+
if self.whisper_model is None:
|
|
140
|
+
await asyncio.to_thread(self._load_models_whisper_only)
|
|
141
|
+
|
|
142
|
+
segments = await asyncio.to_thread(self._file_segments, path)
|
|
143
|
+
for seg in segments:
|
|
144
|
+
yield {"ts": self._fmt_seconds(seg["start"]), "text": seg["text"]}
|
|
145
|
+
|
|
146
|
+
def _load_models_whisper_only(self) -> None: # pragma: no cover
|
|
147
|
+
from faster_whisper import WhisperModel # type: ignore
|
|
148
|
+
|
|
149
|
+
self.whisper_model = WhisperModel(
|
|
150
|
+
self.model_size, device=self.device, compute_type=self.compute_type
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
def _file_segments(self, path: str): # pragma: no cover
|
|
154
|
+
segments, _ = self.whisper_model.transcribe(
|
|
155
|
+
path, beam_size=self.beam_size, language=self.language, vad_filter=True
|
|
156
|
+
)
|
|
157
|
+
out = []
|
|
158
|
+
for seg in segments:
|
|
159
|
+
txt = seg.text.strip()
|
|
160
|
+
if txt:
|
|
161
|
+
out.append({"start": seg.start, "text": txt})
|
|
162
|
+
return out
|
|
163
|
+
|
|
164
|
+
@staticmethod
|
|
165
|
+
def _fmt_seconds(s: float) -> str:
|
|
166
|
+
s = int(s or 0)
|
|
167
|
+
return f"{s // 60:02d}:{s % 60:02d}"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
auth.py — minimal token authentication for the Fitini access gate.
|
|
3
|
+
|
|
4
|
+
This is demo-grade auth: one operator credential (from config.json, overridable with the
|
|
5
|
+
FITINI_PASSPHRASE env var), checked with a constant-time hash compare, issuing an opaque
|
|
6
|
+
in-memory bearer token with a TTL. It is intentionally small — enough to make the login
|
|
7
|
+
screen real — not a production identity system.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import hashlib
|
|
13
|
+
import hmac
|
|
14
|
+
import os
|
|
15
|
+
import secrets
|
|
16
|
+
import time
|
|
17
|
+
from typing import Any, Dict, Optional
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _sha256(value: str) -> str:
|
|
21
|
+
return hashlib.sha256(value.encode("utf-8")).hexdigest()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AuthManager:
|
|
25
|
+
def __init__(self, config: Dict[str, Any]):
|
|
26
|
+
auth = config.get("auth", {})
|
|
27
|
+
self.operator_id = auth.get("operator_id", "OPERATOR")
|
|
28
|
+
passphrase = os.environ.get("FITINI_PASSPHRASE", auth.get("passphrase", "fitini"))
|
|
29
|
+
self.passphrase_hash = _sha256(passphrase)
|
|
30
|
+
self.ttl = int(auth.get("token_ttl_seconds", 3600))
|
|
31
|
+
# token -> expiry epoch
|
|
32
|
+
self._tokens: Dict[str, float] = {}
|
|
33
|
+
|
|
34
|
+
def login(self, operator_id: str, passphrase: str) -> Optional[str]:
|
|
35
|
+
"""Return a bearer token on success, else None."""
|
|
36
|
+
ok_pass = hmac.compare_digest(self.passphrase_hash, _sha256(passphrase or ""))
|
|
37
|
+
# Operator id is accepted loosely (demo): must be non-empty and match prefix.
|
|
38
|
+
ok_op = bool(operator_id) and operator_id.strip().upper().startswith(
|
|
39
|
+
self.operator_id.split("//")[0].strip().upper()
|
|
40
|
+
)
|
|
41
|
+
if ok_pass and ok_op:
|
|
42
|
+
token = secrets.token_urlsafe(32)
|
|
43
|
+
self._tokens[token] = time.time() + self.ttl
|
|
44
|
+
return token
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
def validate(self, token: Optional[str]) -> bool:
|
|
48
|
+
if not token:
|
|
49
|
+
return False
|
|
50
|
+
expiry = self._tokens.get(token)
|
|
51
|
+
if expiry is None:
|
|
52
|
+
return False
|
|
53
|
+
if time.time() > expiry:
|
|
54
|
+
self._tokens.pop(token, None)
|
|
55
|
+
return False
|
|
56
|
+
return True
|
|
57
|
+
|
|
58
|
+
def logout(self, token: Optional[str]) -> None:
|
|
59
|
+
if token:
|
|
60
|
+
self._tokens.pop(token, None)
|