loom-chat 2.0.22__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.
- loom_chat-2.0.22/LICENSE +201 -0
- loom_chat-2.0.22/PKG-INFO +169 -0
- loom_chat-2.0.22/README.md +142 -0
- loom_chat-2.0.22/pyproject.toml +90 -0
- loom_chat-2.0.22/pyproject.toml.orig +68 -0
- loom_chat-2.0.22/src/loom_chat/__init__.py +8 -0
- loom_chat-2.0.22/src/loom_chat/__main__.py +169 -0
- loom_chat-2.0.22/src/loom_chat/app.py +736 -0
- loom_chat-2.0.22/src/loom_chat/engine.py +291 -0
- loom_chat-2.0.22/src/loom_chat/events.py +395 -0
- loom_chat-2.0.22/src/loom_chat/modals.py +228 -0
- loom_chat-2.0.22/src/loom_chat/settings.py +236 -0
- loom_chat-2.0.22/src/loom_chat/widgets.py +312 -0
loom_chat-2.0.22/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
|
|
95
|
+
Derivative 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
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying 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 [yyyy] [name of copyright owner]
|
|
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.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loom-chat
|
|
3
|
+
Version: 2.0.22
|
|
4
|
+
Summary: Console de chat Textual pour essayer loom-ia en quelques minutes.
|
|
5
|
+
Keywords: loom-ia,agents,llm,chat,textual,tui
|
|
6
|
+
Author: Denis Lamard
|
|
7
|
+
Author-email: Denis Lamard <lamard.denis@gmail.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Framework :: AsyncIO
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Natural Language :: French
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Dist: loom-ia[anthropic]==2.0.22
|
|
20
|
+
Requires-Dist: pyyaml>=6
|
|
21
|
+
Requires-Dist: rich>=15
|
|
22
|
+
Requires-Dist: textual>=8.2,<9
|
|
23
|
+
Requires-Python: >=3.14
|
|
24
|
+
Project-URL: Repository, https://github.com/denislamard/loom_v2
|
|
25
|
+
Project-URL: Issues, https://github.com/denislamard/loom_v2/issues
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# loom-chat
|
|
29
|
+
|
|
30
|
+
Console de chat dans le terminal (Textual) pour essayer [loom-ia](https://pypi.org/project/loom-ia/) en quelques minutes : une page, des sessions, des runs, et les demandes de l'agent à l'utilisateur (approbation d'un outil sensible, question du modèle).
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Python 3.14 est requis.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
uv tool install loom-chat
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Lancement
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
cd mon-agent
|
|
44
|
+
loom-chat
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Lancez la console depuis le dossier de votre agent. Elle y lit la config loom comme la commande `loom` : l'amorce `loom-boot.yaml`, la config qu'elle désigne (`loom.yaml`), les agents de `agents/` et leurs prompts. Ce sont des fichiers loom ordinaires : modifiez-les à votre guise, la console les relit à chaque lancement.
|
|
48
|
+
|
|
49
|
+
Dans un dossier sans `loom-boot.yaml`, la console propose de créer un agent prêt à l'emploi (après accord) :
|
|
50
|
+
|
|
51
|
+
| Fichier | Contenu |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `loom-boot.yaml` | L'amorce : où lire la config. |
|
|
54
|
+
| `loom.yaml` | Le modèle, le journal (`data/`), l'utilisateur `local` et son rôle. |
|
|
55
|
+
| `agents/assistant.yaml` | L'agent : modèle, prompt, outils (heure, lecture d'une page avec approbation, question à l'utilisateur). |
|
|
56
|
+
| `prompts/system.md` | Le prompt système. |
|
|
57
|
+
|
|
58
|
+
Le modèle créé est Claude (`claude-haiku-5-5`) si `ANTHROPIC_API_KEY` est définie, chaque message étant alors facturé ; sinon un modèle factice qui joue une démonstration sans clé ni frais.
|
|
59
|
+
|
|
60
|
+
| Option | Rôle |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `--env-file CHEMIN` | Fichier `.env` à lire. Sans l'option, celui que désigne l'amorce, ou le `.env` du dossier. Une variable déjà définie n'est jamais remplacée. |
|
|
63
|
+
| `--user ID` | L'utilisateur de la config au nom duquel agir ; sans l'option, le seul déclaré. Il lui faut `run`, `answer`, `approve` et `self_approve` pour tout faire depuis la console. |
|
|
64
|
+
| `--model fake\|anthropic` | Le modèle des fichiers créés au premier lancement. |
|
|
65
|
+
|
|
66
|
+
### Avec une clé OpenAI
|
|
67
|
+
|
|
68
|
+
La console crée un agent Claude ou la démo ; pour un modèle OpenAI, trois changements, une fois les fichiers créés :
|
|
69
|
+
|
|
70
|
+
1. Installer l'adaptateur OpenAI de loom-ia, que loom-chat n'embarque pas :
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
uv tool install loom-chat --with "loom-ia[openai]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2. Mettre la clé dans le `.env` du dossier de l'agent :
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
OPENAI_API_KEY=sk-…
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
3. Dans `loom.yaml`, remplacer le modèle `model` (garder son `id`, que l'agent cite dans `agents/assistant.yaml`) :
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
models:
|
|
86
|
+
- id: model
|
|
87
|
+
sdk: openai
|
|
88
|
+
model: <nom du modèle chez OpenAI>
|
|
89
|
+
api_key_env: OPENAI_API_KEY
|
|
90
|
+
max_tokens: 2048
|
|
91
|
+
pricing: { input: <prix>, output: <prix> } # dollars par million de tokens ; sans lui, le coût affiché reste à 0
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Retirez `cache:` s'il y en a un : les points de cache sont propres à Anthropic, et refusés avec `sdk: openai`.
|
|
95
|
+
|
|
96
|
+
### Avec une clé Anthropic
|
|
97
|
+
|
|
98
|
+
C'est le modèle créé quand `ANTHROPIC_API_KEY` est définie au premier lancement ; pour passer de la démo à Claude, trois changements :
|
|
99
|
+
|
|
100
|
+
1. Rien à installer : l'adaptateur Anthropic de loom-ia est inclus dans loom-chat.
|
|
101
|
+
|
|
102
|
+
2. Mettre la clé dans le `.env` du dossier de l'agent :
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
ANTHROPIC_API_KEY=sk-ant-…
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
3. Dans `loom.yaml`, remplacer le modèle `model` (garder son `id`, que l'agent cite dans `agents/assistant.yaml`) :
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
models:
|
|
112
|
+
- id: model
|
|
113
|
+
sdk: anthropic
|
|
114
|
+
model: claude-haiku-5-5
|
|
115
|
+
api_key_env: ANTHROPIC_API_KEY
|
|
116
|
+
max_tokens: 2048
|
|
117
|
+
pricing: { input: 0.1, output: 0.5, cache_read: 0.01, cache_write: 0.125 } # dollars par million de tokens
|
|
118
|
+
cache: { system: true, tools: true, messages: true } # facultatif : cache de prompt Anthropic
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Avec un serveur à une URL
|
|
122
|
+
|
|
123
|
+
Un serveur compatible OpenAI (vLLM, Ollama, LM Studio, un fournisseur hébergé…) passe par l'adaptateur OpenAI, avec l'adresse du serveur ; trois changements :
|
|
124
|
+
|
|
125
|
+
1. Installer l'adaptateur OpenAI de loom-ia, que loom-chat n'embarque pas :
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
uv tool install loom-chat --with "loom-ia[openai]"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
2. Si le serveur demande une clé, la mettre dans le `.env` du dossier de l'agent, sous le nom de votre choix ; sinon, rien à faire :
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
LLM_API_KEY=…
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
3. Dans `loom.yaml`, remplacer le modèle `model` (garder son `id`, que l'agent cite dans `agents/assistant.yaml`) :
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
models:
|
|
141
|
+
- id: model
|
|
142
|
+
sdk: openai
|
|
143
|
+
model: <nom du modèle sur le serveur>
|
|
144
|
+
base_url: http://localhost:11434/v1 # l'adresse du serveur, jusqu'au /v1
|
|
145
|
+
api_key_env: LLM_API_KEY # à retirer si le serveur ne demande pas de clé
|
|
146
|
+
max_tokens: 2048
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
L'agent a des outils : le modèle servi doit savoir les appeler. Sans `pricing`, le coût affiché reste à 0. Les variables `OPENAI_BASE_URL` et `ANTHROPIC_BASE_URL` ne sont jamais lues : seule la config dit où partent les requêtes.
|
|
150
|
+
|
|
151
|
+
Avec plusieurs agents dans `agents/`, la console demande au démarrage avec lequel parler (Ctrl+A pour en changer : une nouvelle session s'ouvre avec lui).
|
|
152
|
+
|
|
153
|
+
## Raccourcis
|
|
154
|
+
|
|
155
|
+
| Touche | Action |
|
|
156
|
+
|---|---|
|
|
157
|
+
| Entrée | Envoyer le message ; rouvre la question ou l'approbation en attente |
|
|
158
|
+
| Ctrl+N | Nouvelle session |
|
|
159
|
+
| Ctrl+A | Choisir l'agent |
|
|
160
|
+
| Ctrl+X | Annuler le run en cours |
|
|
161
|
+
| Ctrl+R | Reprendre le dernier run interrompu |
|
|
162
|
+
| Échap (question) | Répondre plus tard : la question reste ouverte |
|
|
163
|
+
| Ctrl+Q | Quitter |
|
|
164
|
+
|
|
165
|
+
Le journal fait foi : une session fermée en plein run se rouvre telle quelle au lancement suivant, avec ses demandes en attente.
|
|
166
|
+
|
|
167
|
+
## Licence
|
|
168
|
+
|
|
169
|
+
Apache-2.0.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# loom-chat
|
|
2
|
+
|
|
3
|
+
Console de chat dans le terminal (Textual) pour essayer [loom-ia](https://pypi.org/project/loom-ia/) en quelques minutes : une page, des sessions, des runs, et les demandes de l'agent à l'utilisateur (approbation d'un outil sensible, question du modèle).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Python 3.14 est requis.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv tool install loom-chat
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Lancement
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd mon-agent
|
|
17
|
+
loom-chat
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Lancez la console depuis le dossier de votre agent. Elle y lit la config loom comme la commande `loom` : l'amorce `loom-boot.yaml`, la config qu'elle désigne (`loom.yaml`), les agents de `agents/` et leurs prompts. Ce sont des fichiers loom ordinaires : modifiez-les à votre guise, la console les relit à chaque lancement.
|
|
21
|
+
|
|
22
|
+
Dans un dossier sans `loom-boot.yaml`, la console propose de créer un agent prêt à l'emploi (après accord) :
|
|
23
|
+
|
|
24
|
+
| Fichier | Contenu |
|
|
25
|
+
|---|---|
|
|
26
|
+
| `loom-boot.yaml` | L'amorce : où lire la config. |
|
|
27
|
+
| `loom.yaml` | Le modèle, le journal (`data/`), l'utilisateur `local` et son rôle. |
|
|
28
|
+
| `agents/assistant.yaml` | L'agent : modèle, prompt, outils (heure, lecture d'une page avec approbation, question à l'utilisateur). |
|
|
29
|
+
| `prompts/system.md` | Le prompt système. |
|
|
30
|
+
|
|
31
|
+
Le modèle créé est Claude (`claude-haiku-5-5`) si `ANTHROPIC_API_KEY` est définie, chaque message étant alors facturé ; sinon un modèle factice qui joue une démonstration sans clé ni frais.
|
|
32
|
+
|
|
33
|
+
| Option | Rôle |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `--env-file CHEMIN` | Fichier `.env` à lire. Sans l'option, celui que désigne l'amorce, ou le `.env` du dossier. Une variable déjà définie n'est jamais remplacée. |
|
|
36
|
+
| `--user ID` | L'utilisateur de la config au nom duquel agir ; sans l'option, le seul déclaré. Il lui faut `run`, `answer`, `approve` et `self_approve` pour tout faire depuis la console. |
|
|
37
|
+
| `--model fake\|anthropic` | Le modèle des fichiers créés au premier lancement. |
|
|
38
|
+
|
|
39
|
+
### Avec une clé OpenAI
|
|
40
|
+
|
|
41
|
+
La console crée un agent Claude ou la démo ; pour un modèle OpenAI, trois changements, une fois les fichiers créés :
|
|
42
|
+
|
|
43
|
+
1. Installer l'adaptateur OpenAI de loom-ia, que loom-chat n'embarque pas :
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv tool install loom-chat --with "loom-ia[openai]"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. Mettre la clé dans le `.env` du dossier de l'agent :
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
OPENAI_API_KEY=sk-…
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
3. Dans `loom.yaml`, remplacer le modèle `model` (garder son `id`, que l'agent cite dans `agents/assistant.yaml`) :
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
models:
|
|
59
|
+
- id: model
|
|
60
|
+
sdk: openai
|
|
61
|
+
model: <nom du modèle chez OpenAI>
|
|
62
|
+
api_key_env: OPENAI_API_KEY
|
|
63
|
+
max_tokens: 2048
|
|
64
|
+
pricing: { input: <prix>, output: <prix> } # dollars par million de tokens ; sans lui, le coût affiché reste à 0
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Retirez `cache:` s'il y en a un : les points de cache sont propres à Anthropic, et refusés avec `sdk: openai`.
|
|
68
|
+
|
|
69
|
+
### Avec une clé Anthropic
|
|
70
|
+
|
|
71
|
+
C'est le modèle créé quand `ANTHROPIC_API_KEY` est définie au premier lancement ; pour passer de la démo à Claude, trois changements :
|
|
72
|
+
|
|
73
|
+
1. Rien à installer : l'adaptateur Anthropic de loom-ia est inclus dans loom-chat.
|
|
74
|
+
|
|
75
|
+
2. Mettre la clé dans le `.env` du dossier de l'agent :
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
ANTHROPIC_API_KEY=sk-ant-…
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. Dans `loom.yaml`, remplacer le modèle `model` (garder son `id`, que l'agent cite dans `agents/assistant.yaml`) :
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
models:
|
|
85
|
+
- id: model
|
|
86
|
+
sdk: anthropic
|
|
87
|
+
model: claude-haiku-5-5
|
|
88
|
+
api_key_env: ANTHROPIC_API_KEY
|
|
89
|
+
max_tokens: 2048
|
|
90
|
+
pricing: { input: 0.1, output: 0.5, cache_read: 0.01, cache_write: 0.125 } # dollars par million de tokens
|
|
91
|
+
cache: { system: true, tools: true, messages: true } # facultatif : cache de prompt Anthropic
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Avec un serveur à une URL
|
|
95
|
+
|
|
96
|
+
Un serveur compatible OpenAI (vLLM, Ollama, LM Studio, un fournisseur hébergé…) passe par l'adaptateur OpenAI, avec l'adresse du serveur ; trois changements :
|
|
97
|
+
|
|
98
|
+
1. Installer l'adaptateur OpenAI de loom-ia, que loom-chat n'embarque pas :
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
uv tool install loom-chat --with "loom-ia[openai]"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
2. Si le serveur demande une clé, la mettre dans le `.env` du dossier de l'agent, sous le nom de votre choix ; sinon, rien à faire :
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
LLM_API_KEY=…
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
3. Dans `loom.yaml`, remplacer le modèle `model` (garder son `id`, que l'agent cite dans `agents/assistant.yaml`) :
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
models:
|
|
114
|
+
- id: model
|
|
115
|
+
sdk: openai
|
|
116
|
+
model: <nom du modèle sur le serveur>
|
|
117
|
+
base_url: http://localhost:11434/v1 # l'adresse du serveur, jusqu'au /v1
|
|
118
|
+
api_key_env: LLM_API_KEY # à retirer si le serveur ne demande pas de clé
|
|
119
|
+
max_tokens: 2048
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
L'agent a des outils : le modèle servi doit savoir les appeler. Sans `pricing`, le coût affiché reste à 0. Les variables `OPENAI_BASE_URL` et `ANTHROPIC_BASE_URL` ne sont jamais lues : seule la config dit où partent les requêtes.
|
|
123
|
+
|
|
124
|
+
Avec plusieurs agents dans `agents/`, la console demande au démarrage avec lequel parler (Ctrl+A pour en changer : une nouvelle session s'ouvre avec lui).
|
|
125
|
+
|
|
126
|
+
## Raccourcis
|
|
127
|
+
|
|
128
|
+
| Touche | Action |
|
|
129
|
+
|---|---|
|
|
130
|
+
| Entrée | Envoyer le message ; rouvre la question ou l'approbation en attente |
|
|
131
|
+
| Ctrl+N | Nouvelle session |
|
|
132
|
+
| Ctrl+A | Choisir l'agent |
|
|
133
|
+
| Ctrl+X | Annuler le run en cours |
|
|
134
|
+
| Ctrl+R | Reprendre le dernier run interrompu |
|
|
135
|
+
| Échap (question) | Répondre plus tard : la question reste ouverte |
|
|
136
|
+
| Ctrl+Q | Quitter |
|
|
137
|
+
|
|
138
|
+
Le journal fait foi : une session fermée en plein run se rouvre telle quelle au lancement suivant, avec ses demandes en attente.
|
|
139
|
+
|
|
140
|
+
## Licence
|
|
141
|
+
|
|
142
|
+
Apache-2.0.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "loom-chat"
|
|
3
|
+
version = "2.0.22"
|
|
4
|
+
description = "Console de chat Textual pour essayer loom-ia en quelques minutes."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.14"
|
|
9
|
+
keywords = [
|
|
10
|
+
"loom-ia",
|
|
11
|
+
"agents",
|
|
12
|
+
"llm",
|
|
13
|
+
"chat",
|
|
14
|
+
"textual",
|
|
15
|
+
"tui",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Framework :: AsyncIO",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Natural Language :: French",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"loom-ia[anthropic]==2.0.22",
|
|
30
|
+
"pyyaml>=6",
|
|
31
|
+
"rich>=15",
|
|
32
|
+
"textual>=8.2,<9",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[[project.authors]]
|
|
36
|
+
name = "Denis Lamard"
|
|
37
|
+
email = "lamard.denis@gmail.com"
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Repository = "https://github.com/denislamard/loom_v2"
|
|
41
|
+
Issues = "https://github.com/denislamard/loom_v2/issues"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
loom-chat = "loom_chat.__main__:main"
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["uv_build>=0.13.8,<0.14.0"]
|
|
48
|
+
build-backend = "uv_build"
|
|
49
|
+
|
|
50
|
+
[tool.uv.sources.loom-ia]
|
|
51
|
+
path = ".."
|
|
52
|
+
editable = true
|
|
53
|
+
|
|
54
|
+
[tool.ruff]
|
|
55
|
+
extend = "../pyproject.toml"
|
|
56
|
+
src = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff.lint.per-file-ignores]
|
|
59
|
+
"tests/**/*.py" = [
|
|
60
|
+
"D100",
|
|
61
|
+
"D101",
|
|
62
|
+
"D102",
|
|
63
|
+
"D103",
|
|
64
|
+
"D104",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
[tool.pyright]
|
|
68
|
+
pythonVersion = "3.14"
|
|
69
|
+
typeCheckingMode = "strict"
|
|
70
|
+
include = [
|
|
71
|
+
"src",
|
|
72
|
+
"tests",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
addopts = [
|
|
77
|
+
"--strict-markers",
|
|
78
|
+
"--strict-config",
|
|
79
|
+
]
|
|
80
|
+
testpaths = ["tests"]
|
|
81
|
+
asyncio_mode = "auto"
|
|
82
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
83
|
+
|
|
84
|
+
[dependency-groups]
|
|
85
|
+
dev = [
|
|
86
|
+
"pyright>=1.1.414",
|
|
87
|
+
"pytest>=9.2",
|
|
88
|
+
"pytest-asyncio>=1.5",
|
|
89
|
+
"ruff>=0.16.8",
|
|
90
|
+
]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "loom-chat"
|
|
3
|
+
version = "2.0.22"
|
|
4
|
+
description = "Console de chat Textual pour essayer loom-ia en quelques minutes."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.14"
|
|
9
|
+
authors = [{ name = "Denis Lamard", email = "lamard.denis@gmail.com" }]
|
|
10
|
+
keywords = ["loom-ia", "agents", "llm", "chat", "textual", "tui"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Environment :: Console",
|
|
13
|
+
"Framework :: AsyncIO",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Natural Language :: French",
|
|
16
|
+
"Operating System :: POSIX :: Linux",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
# loom-chat importe des modules internes de loom-ia et suit ses versions : la même, exactement.
|
|
24
|
+
# tests/test_package.py vérifie que les deux numéros restent égaux.
|
|
25
|
+
dependencies = ["loom-ia[anthropic]==2.0.22", "pyyaml>=6", "rich>=15", "textual>=8.2,<9"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Repository = "https://github.com/denislamard/loom_v2"
|
|
29
|
+
Issues = "https://github.com/denislamard/loom_v2/issues"
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
loom-chat = "loom_chat.__main__:main"
|
|
33
|
+
|
|
34
|
+
[build-system]
|
|
35
|
+
requires = ["uv_build>=0.13.8,<0.14.0"]
|
|
36
|
+
build-backend = "uv_build"
|
|
37
|
+
|
|
38
|
+
# Développement local : loom-ia depuis les sources du dépôt parent.
|
|
39
|
+
# Sans effet sur le paquet publié (vérifié en CI par `uv build --no-sources`).
|
|
40
|
+
[tool.uv.sources]
|
|
41
|
+
loom-ia = { path = "..", editable = true }
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"pyright>=1.1.414",
|
|
46
|
+
"pytest>=9.2",
|
|
47
|
+
"pytest-asyncio>=1.5",
|
|
48
|
+
"ruff>=0.16.8",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
# Les règles du dépôt, avec les chemins de loom-chat.
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
extend = "../pyproject.toml"
|
|
54
|
+
src = ["src"]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint.per-file-ignores]
|
|
57
|
+
"tests/**/*.py" = ["D100", "D101", "D102", "D103", "D104"]
|
|
58
|
+
|
|
59
|
+
[tool.pyright]
|
|
60
|
+
pythonVersion = "3.14"
|
|
61
|
+
typeCheckingMode = "strict"
|
|
62
|
+
include = ["src", "tests"]
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
addopts = ["--strict-markers", "--strict-config"]
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
asyncio_mode = "auto"
|
|
68
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Console de chat pour loom-ia : une page, des sessions, des runs, des demandes à l'utilisateur."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("loom-chat")
|
|
7
|
+
except PackageNotFoundError: # lancé depuis les sources, sans installation du paquet
|
|
8
|
+
__version__ = "0.0.0+sources"
|