PraisonAI 0.0.50__tar.gz → 0.0.53__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.
Potentially problematic release.
This version of PraisonAI might be problematic. Click here for more details.
- {praisonai-0.0.50 → praisonai-0.0.53}/PKG-INFO +58 -23
- {praisonai-0.0.50 → praisonai-0.0.53}/README.md +56 -23
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/deploy.py +1 -1
- praisonai-0.0.53/praisonai/ui/context.py +201 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/pyproject.toml +4 -2
- praisonai-0.0.50/praisonai/ui/context.py +0 -172
- {praisonai-0.0.50 → praisonai-0.0.53}/LICENSE +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/__init__.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/__main__.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/agents_generator.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/auto.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/chainlit_ui.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/cli.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/inbuilt_tools/__init__.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/inbuilt_tools/autogen_tools.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/inc/__init__.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/inc/models.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/android-chrome-192x192.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/android-chrome-512x512.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/apple-touch-icon.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/fantasy.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/favicon-16x16.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/favicon-32x32.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/favicon.ico +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/game.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/logo_dark.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/logo_light.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/movie.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/public/thriller.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/test.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/chat.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/code.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/public/fantasy.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/public/game.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/public/logo_dark.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/public/logo_light.png +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/public/movie.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/public/thriller.svg +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/ui/sql_alchemy.py +0 -0
- {praisonai-0.0.50 → praisonai-0.0.53}/praisonai/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PraisonAI
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.53
|
|
4
4
|
Summary: PraisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration.
|
|
5
5
|
Author: Mervin Praison
|
|
6
6
|
Requires-Python: >=3.10,<3.13
|
|
@@ -24,6 +24,7 @@ Requires-Dist: chainlit (>=1.1.301,<2.0.0) ; extra == "ui" or extra == "chat" or
|
|
|
24
24
|
Requires-Dist: crewai (>=0.32.0)
|
|
25
25
|
Requires-Dist: flask (>=3.0.0) ; extra == "api"
|
|
26
26
|
Requires-Dist: gradio (>=4.26.0) ; extra == "gradio"
|
|
27
|
+
Requires-Dist: greenlet (>=3.0.3) ; extra == "code"
|
|
27
28
|
Requires-Dist: langchain-anthropic (>=0.1.13) ; extra == "anthropic"
|
|
28
29
|
Requires-Dist: langchain-cohere (>=0.1.4) ; extra == "cohere"
|
|
29
30
|
Requires-Dist: langchain-google-genai (>=1.0.4) ; extra == "google"
|
|
@@ -45,6 +46,13 @@ Description-Content-Type: text/markdown
|
|
|
45
46
|
<img alt="PraisonAI Logo" src="docs/images/praisonai-logo-black-large.png">
|
|
46
47
|
</picture>
|
|
47
48
|
</p>
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<a href="https://github.com/MervinPraison/PraisonAI"><img src="https://static.pepy.tech/badge/PraisonAI" alt="Total Downloads"></a>
|
|
52
|
+
<a href="https://github.com/MervinPraison/PraisonAI"><img src="https://img.shields.io/github/v/release/MervinPraison/PraisonAI" alt="Latest Stable Version"></a>
|
|
53
|
+
<a href="https://github.com/MervinPraison/PraisonAI"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"></a>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
48
56
|
<div align="center">
|
|
49
57
|
|
|
50
58
|
# Praison AI
|
|
@@ -53,12 +61,13 @@ Description-Content-Type: text/markdown
|
|
|
53
61
|
|
|
54
62
|
Praison AI, leveraging both AutoGen and CrewAI or any other agent framework, represents a low-code, centralised framework designed to simplify the creation and orchestration of multi-agent systems for various LLM applications, emphasizing ease of use, customization, and human-agent interaction.
|
|
55
63
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
| Basic
|
|
64
|
+
| | Cookbook | Open in Colab |
|
|
65
|
+
| ------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| Basic | PraisonAI | <a target="_blank" href="https://colab.research.google.com/github/MervinPraison/PraisonAI/blob/main/cookbooks/praisonai-googlecolab.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a> |
|
|
59
67
|
| Include Tools | PraisonAI Tools | <a target="_blank" href="https://colab.research.google.com/github/MervinPraison/PraisonAI/blob/main/cookbooks/praisonai-tools-googlecolab.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a> |
|
|
60
68
|
|
|
61
69
|
## TL;DR
|
|
70
|
+
|
|
62
71
|
```bash
|
|
63
72
|
pip install praisonai
|
|
64
73
|
export OPENAI_API_KEY="Enter your API key"
|
|
@@ -66,6 +75,14 @@ praisonai --init create a movie script about dog in moon
|
|
|
66
75
|
praisonai
|
|
67
76
|
```
|
|
68
77
|
|
|
78
|
+
## Different User Interfaces:
|
|
79
|
+
|
|
80
|
+
| Interface | Description | URL |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praison.ai/ui/ui](https://docs.praison.ai/ui/ui) |
|
|
83
|
+
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praison.ai/ui/chat](https://docs.praison.ai/ui/chat) |
|
|
84
|
+
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praison.ai/ui/code](https://docs.praison.ai/ui/code) |
|
|
85
|
+
|
|
69
86
|
## Table of Contents
|
|
70
87
|
|
|
71
88
|
- [Installation](#installation)
|
|
@@ -97,13 +114,14 @@ export OPENAI_API_KEY="Enter your API key"
|
|
|
97
114
|
Generate your OPENAI API KEY from here: https://platform.openai.com/api-keys
|
|
98
115
|
|
|
99
116
|
Note: You can use other providers such as Ollama, Mistral ... etc. Details are provided at the bottom.
|
|
100
|
-
|
|
117
|
+
|
|
101
118
|
```bash
|
|
102
119
|
praisonai --init create a movie script about dog in moon
|
|
103
120
|
```
|
|
121
|
+
|
|
104
122
|
This will automatically create agents.yaml file in the current directory.
|
|
105
123
|
|
|
106
|
-
### To
|
|
124
|
+
### To initialise with a specific agent framework (Optional):
|
|
107
125
|
|
|
108
126
|
```bash
|
|
109
127
|
praisonai --framework autogen --init create movie script about cat in mars
|
|
@@ -115,8 +133,8 @@ praisonai --framework autogen --init create movie script about cat in mars
|
|
|
115
133
|
praisonai
|
|
116
134
|
```
|
|
117
135
|
|
|
118
|
-
or
|
|
119
|
-
|
|
136
|
+
or
|
|
137
|
+
|
|
120
138
|
```bash
|
|
121
139
|
python -m praisonai
|
|
122
140
|
```
|
|
@@ -135,6 +153,14 @@ praisonai --auto create a movie script about Dog in Moon
|
|
|
135
153
|
|
|
136
154
|
## User Interface
|
|
137
155
|
|
|
156
|
+
## PraisonAI User Interfaces:
|
|
157
|
+
|
|
158
|
+
| Interface | Description | URL |
|
|
159
|
+
| --------- | ------------------------------------------ | --------------------------------------------------------------------- |
|
|
160
|
+
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praisonai.com/ui/ui](https://docs.praison.ai/ui/ui) |
|
|
161
|
+
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praisonai.com/ui/chat](https://docs.praison.ai/ui/chat) |
|
|
162
|
+
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praisonai.com/ui/code](https://docs.praison.ai/ui/code) |
|
|
163
|
+
|
|
138
164
|
```bash
|
|
139
165
|
pip install -U "praisonai[ui]"
|
|
140
166
|
export OPENAI_API_KEY="Enter your API key"
|
|
@@ -143,7 +169,7 @@ export CHAINLIT_AUTH_SECRET=xxxxxxxx
|
|
|
143
169
|
praisonai ui
|
|
144
170
|
```
|
|
145
171
|
|
|
146
|
-
or
|
|
172
|
+
or
|
|
147
173
|
|
|
148
174
|
```
|
|
149
175
|
python -m praisonai ui
|
|
@@ -151,7 +177,7 @@ python -m praisonai ui
|
|
|
151
177
|
|
|
152
178
|
## Praison AI Chat
|
|
153
179
|
|
|
154
|
-
|
|
180
|
+
- https://docs.praison.ai/chat/
|
|
155
181
|
|
|
156
182
|
```bash
|
|
157
183
|
pip install "praisonai[chat]"
|
|
@@ -161,10 +187,11 @@ praisonai chat
|
|
|
161
187
|
|
|
162
188
|
## Create Custom Tools
|
|
163
189
|
|
|
164
|
-
|
|
190
|
+
- https://docs.praison.ai/tools/custom/
|
|
165
191
|
|
|
166
192
|
### Step 1: Pre-requisite to Create a Custom Tool
|
|
167
|
-
|
|
193
|
+
|
|
194
|
+
`agents.yaml` file should be present in the current directory.
|
|
168
195
|
|
|
169
196
|
If it doesn't exist, create it by running the command `praisonai --init research about the latest AI News and prepare a detailed report`.
|
|
170
197
|
|
|
@@ -201,14 +228,15 @@ roles:
|
|
|
201
228
|
role: Research Analyst
|
|
202
229
|
tasks:
|
|
203
230
|
gather_data:
|
|
204
|
-
description:
|
|
231
|
+
description:
|
|
232
|
+
Conduct in-depth research on the latest AI News trends from reputable
|
|
205
233
|
sources.
|
|
206
234
|
expected_output: Comprehensive report on current AI News trends.
|
|
207
235
|
tools:
|
|
208
|
-
|
|
236
|
+
- InternetSearchTool
|
|
209
237
|
```
|
|
210
238
|
|
|
211
|
-
## Agents Playbook
|
|
239
|
+
## Agents Playbook
|
|
212
240
|
|
|
213
241
|
### Simple Playbook Example
|
|
214
242
|
|
|
@@ -217,23 +245,23 @@ framework: crewai
|
|
|
217
245
|
topic: Artificial Intelligence
|
|
218
246
|
roles:
|
|
219
247
|
screenwriter:
|
|
220
|
-
backstory:
|
|
248
|
+
backstory: "Skilled in crafting scripts with engaging dialogue about {topic}."
|
|
221
249
|
goal: Create scripts from concepts.
|
|
222
250
|
role: Screenwriter
|
|
223
251
|
tasks:
|
|
224
252
|
scriptwriting_task:
|
|
225
|
-
description:
|
|
226
|
-
expected_output:
|
|
253
|
+
description: "Develop scripts with compelling characters and dialogue about {topic}."
|
|
254
|
+
expected_output: "Complete script ready for production."
|
|
227
255
|
```
|
|
228
256
|
|
|
229
257
|
## Use 100+ Models
|
|
230
258
|
|
|
231
|
-
|
|
259
|
+
- https://docs.praison.ai/models/
|
|
232
260
|
|
|
233
261
|
## Include praisonai package in your project
|
|
234
262
|
|
|
235
|
-
|
|
236
|
-
|
|
263
|
+
- https://docs.praison.ai/developers/wrapper
|
|
264
|
+
- https://docs.praison.ai/developers/wrapper-tools/
|
|
237
265
|
|
|
238
266
|
## Option 1: Using RAW YAML
|
|
239
267
|
|
|
@@ -268,8 +296,7 @@ print(result)
|
|
|
268
296
|
|
|
269
297
|
## Option 2: Using separate agents.yaml file
|
|
270
298
|
|
|
271
|
-
|
|
272
|
-
Note: Please create agents.yaml file before hand.
|
|
299
|
+
Note: Please create agents.yaml file before hand.
|
|
273
300
|
|
|
274
301
|
```python
|
|
275
302
|
from praisonai import PraisonAI
|
|
@@ -285,16 +312,19 @@ if __name__ == "__main__":
|
|
|
285
312
|
## Commands to Install Dependencies:
|
|
286
313
|
|
|
287
314
|
1. **Install all dependencies, including dev dependencies:**
|
|
315
|
+
|
|
288
316
|
```sh
|
|
289
317
|
poetry install
|
|
290
318
|
```
|
|
291
319
|
|
|
292
320
|
2. **Install only documentation dependencies:**
|
|
321
|
+
|
|
293
322
|
```sh
|
|
294
323
|
poetry install --with docs
|
|
295
324
|
```
|
|
296
325
|
|
|
297
326
|
3. **Install only test dependencies:**
|
|
327
|
+
|
|
298
328
|
```sh
|
|
299
329
|
poetry install --with test
|
|
300
330
|
```
|
|
@@ -319,3 +349,8 @@ This configuration ensures that your development dependencies are correctly cate
|
|
|
319
349
|
## Star History
|
|
320
350
|
|
|
321
351
|
[](https://docs.praison.ai)
|
|
352
|
+
|
|
353
|
+
## License
|
|
354
|
+
|
|
355
|
+
Praison AI is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
|
|
356
|
+
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
<img alt="PraisonAI Logo" src="docs/images/praisonai-logo-black-large.png">
|
|
6
6
|
</picture>
|
|
7
7
|
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/MervinPraison/PraisonAI"><img src="https://static.pepy.tech/badge/PraisonAI" alt="Total Downloads"></a>
|
|
11
|
+
<a href="https://github.com/MervinPraison/PraisonAI"><img src="https://img.shields.io/github/v/release/MervinPraison/PraisonAI" alt="Latest Stable Version"></a>
|
|
12
|
+
<a href="https://github.com/MervinPraison/PraisonAI"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
8
15
|
<div align="center">
|
|
9
16
|
|
|
10
17
|
# Praison AI
|
|
@@ -13,12 +20,13 @@
|
|
|
13
20
|
|
|
14
21
|
Praison AI, leveraging both AutoGen and CrewAI or any other agent framework, represents a low-code, centralised framework designed to simplify the creation and orchestration of multi-agent systems for various LLM applications, emphasizing ease of use, customization, and human-agent interaction.
|
|
15
22
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
| Basic
|
|
23
|
+
| | Cookbook | Open in Colab |
|
|
24
|
+
| ------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| Basic | PraisonAI | <a target="_blank" href="https://colab.research.google.com/github/MervinPraison/PraisonAI/blob/main/cookbooks/praisonai-googlecolab.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a> |
|
|
19
26
|
| Include Tools | PraisonAI Tools | <a target="_blank" href="https://colab.research.google.com/github/MervinPraison/PraisonAI/blob/main/cookbooks/praisonai-tools-googlecolab.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a> |
|
|
20
27
|
|
|
21
28
|
## TL;DR
|
|
29
|
+
|
|
22
30
|
```bash
|
|
23
31
|
pip install praisonai
|
|
24
32
|
export OPENAI_API_KEY="Enter your API key"
|
|
@@ -26,6 +34,14 @@ praisonai --init create a movie script about dog in moon
|
|
|
26
34
|
praisonai
|
|
27
35
|
```
|
|
28
36
|
|
|
37
|
+
## Different User Interfaces:
|
|
38
|
+
|
|
39
|
+
| Interface | Description | URL |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praison.ai/ui/ui](https://docs.praison.ai/ui/ui) |
|
|
42
|
+
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praison.ai/ui/chat](https://docs.praison.ai/ui/chat) |
|
|
43
|
+
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praison.ai/ui/code](https://docs.praison.ai/ui/code) |
|
|
44
|
+
|
|
29
45
|
## Table of Contents
|
|
30
46
|
|
|
31
47
|
- [Installation](#installation)
|
|
@@ -57,13 +73,14 @@ export OPENAI_API_KEY="Enter your API key"
|
|
|
57
73
|
Generate your OPENAI API KEY from here: https://platform.openai.com/api-keys
|
|
58
74
|
|
|
59
75
|
Note: You can use other providers such as Ollama, Mistral ... etc. Details are provided at the bottom.
|
|
60
|
-
|
|
76
|
+
|
|
61
77
|
```bash
|
|
62
78
|
praisonai --init create a movie script about dog in moon
|
|
63
79
|
```
|
|
80
|
+
|
|
64
81
|
This will automatically create agents.yaml file in the current directory.
|
|
65
82
|
|
|
66
|
-
### To
|
|
83
|
+
### To initialise with a specific agent framework (Optional):
|
|
67
84
|
|
|
68
85
|
```bash
|
|
69
86
|
praisonai --framework autogen --init create movie script about cat in mars
|
|
@@ -75,8 +92,8 @@ praisonai --framework autogen --init create movie script about cat in mars
|
|
|
75
92
|
praisonai
|
|
76
93
|
```
|
|
77
94
|
|
|
78
|
-
or
|
|
79
|
-
|
|
95
|
+
or
|
|
96
|
+
|
|
80
97
|
```bash
|
|
81
98
|
python -m praisonai
|
|
82
99
|
```
|
|
@@ -95,6 +112,14 @@ praisonai --auto create a movie script about Dog in Moon
|
|
|
95
112
|
|
|
96
113
|
## User Interface
|
|
97
114
|
|
|
115
|
+
## PraisonAI User Interfaces:
|
|
116
|
+
|
|
117
|
+
| Interface | Description | URL |
|
|
118
|
+
| --------- | ------------------------------------------ | --------------------------------------------------------------------- |
|
|
119
|
+
| **UI** | Multi Agents such as CrewAI or AutoGen | [https://docs.praisonai.com/ui/ui](https://docs.praison.ai/ui/ui) |
|
|
120
|
+
| **Chat** | Chat with 100+ LLMs, single AI Agent | [https://docs.praisonai.com/ui/chat](https://docs.praison.ai/ui/chat) |
|
|
121
|
+
| **Code** | Chat with entire Codebase, single AI Agent | [https://docs.praisonai.com/ui/code](https://docs.praison.ai/ui/code) |
|
|
122
|
+
|
|
98
123
|
```bash
|
|
99
124
|
pip install -U "praisonai[ui]"
|
|
100
125
|
export OPENAI_API_KEY="Enter your API key"
|
|
@@ -103,7 +128,7 @@ export CHAINLIT_AUTH_SECRET=xxxxxxxx
|
|
|
103
128
|
praisonai ui
|
|
104
129
|
```
|
|
105
130
|
|
|
106
|
-
or
|
|
131
|
+
or
|
|
107
132
|
|
|
108
133
|
```
|
|
109
134
|
python -m praisonai ui
|
|
@@ -111,7 +136,7 @@ python -m praisonai ui
|
|
|
111
136
|
|
|
112
137
|
## Praison AI Chat
|
|
113
138
|
|
|
114
|
-
|
|
139
|
+
- https://docs.praison.ai/chat/
|
|
115
140
|
|
|
116
141
|
```bash
|
|
117
142
|
pip install "praisonai[chat]"
|
|
@@ -121,10 +146,11 @@ praisonai chat
|
|
|
121
146
|
|
|
122
147
|
## Create Custom Tools
|
|
123
148
|
|
|
124
|
-
|
|
149
|
+
- https://docs.praison.ai/tools/custom/
|
|
125
150
|
|
|
126
151
|
### Step 1: Pre-requisite to Create a Custom Tool
|
|
127
|
-
|
|
152
|
+
|
|
153
|
+
`agents.yaml` file should be present in the current directory.
|
|
128
154
|
|
|
129
155
|
If it doesn't exist, create it by running the command `praisonai --init research about the latest AI News and prepare a detailed report`.
|
|
130
156
|
|
|
@@ -161,14 +187,15 @@ roles:
|
|
|
161
187
|
role: Research Analyst
|
|
162
188
|
tasks:
|
|
163
189
|
gather_data:
|
|
164
|
-
description:
|
|
190
|
+
description:
|
|
191
|
+
Conduct in-depth research on the latest AI News trends from reputable
|
|
165
192
|
sources.
|
|
166
193
|
expected_output: Comprehensive report on current AI News trends.
|
|
167
194
|
tools:
|
|
168
|
-
|
|
195
|
+
- InternetSearchTool
|
|
169
196
|
```
|
|
170
197
|
|
|
171
|
-
## Agents Playbook
|
|
198
|
+
## Agents Playbook
|
|
172
199
|
|
|
173
200
|
### Simple Playbook Example
|
|
174
201
|
|
|
@@ -177,23 +204,23 @@ framework: crewai
|
|
|
177
204
|
topic: Artificial Intelligence
|
|
178
205
|
roles:
|
|
179
206
|
screenwriter:
|
|
180
|
-
backstory:
|
|
207
|
+
backstory: "Skilled in crafting scripts with engaging dialogue about {topic}."
|
|
181
208
|
goal: Create scripts from concepts.
|
|
182
209
|
role: Screenwriter
|
|
183
210
|
tasks:
|
|
184
211
|
scriptwriting_task:
|
|
185
|
-
description:
|
|
186
|
-
expected_output:
|
|
212
|
+
description: "Develop scripts with compelling characters and dialogue about {topic}."
|
|
213
|
+
expected_output: "Complete script ready for production."
|
|
187
214
|
```
|
|
188
215
|
|
|
189
216
|
## Use 100+ Models
|
|
190
217
|
|
|
191
|
-
|
|
218
|
+
- https://docs.praison.ai/models/
|
|
192
219
|
|
|
193
220
|
## Include praisonai package in your project
|
|
194
221
|
|
|
195
|
-
|
|
196
|
-
|
|
222
|
+
- https://docs.praison.ai/developers/wrapper
|
|
223
|
+
- https://docs.praison.ai/developers/wrapper-tools/
|
|
197
224
|
|
|
198
225
|
## Option 1: Using RAW YAML
|
|
199
226
|
|
|
@@ -228,8 +255,7 @@ print(result)
|
|
|
228
255
|
|
|
229
256
|
## Option 2: Using separate agents.yaml file
|
|
230
257
|
|
|
231
|
-
|
|
232
|
-
Note: Please create agents.yaml file before hand.
|
|
258
|
+
Note: Please create agents.yaml file before hand.
|
|
233
259
|
|
|
234
260
|
```python
|
|
235
261
|
from praisonai import PraisonAI
|
|
@@ -245,16 +271,19 @@ if __name__ == "__main__":
|
|
|
245
271
|
## Commands to Install Dependencies:
|
|
246
272
|
|
|
247
273
|
1. **Install all dependencies, including dev dependencies:**
|
|
274
|
+
|
|
248
275
|
```sh
|
|
249
276
|
poetry install
|
|
250
277
|
```
|
|
251
278
|
|
|
252
279
|
2. **Install only documentation dependencies:**
|
|
280
|
+
|
|
253
281
|
```sh
|
|
254
282
|
poetry install --with docs
|
|
255
283
|
```
|
|
256
284
|
|
|
257
285
|
3. **Install only test dependencies:**
|
|
286
|
+
|
|
258
287
|
```sh
|
|
259
288
|
poetry install --with test
|
|
260
289
|
```
|
|
@@ -278,4 +307,8 @@ This configuration ensures that your development dependencies are correctly cate
|
|
|
278
307
|
|
|
279
308
|
## Star History
|
|
280
309
|
|
|
281
|
-
[](https://docs.praison.ai)
|
|
310
|
+
[](https://docs.praison.ai)
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
Praison AI is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.
|
|
@@ -56,7 +56,7 @@ class CloudDeployer:
|
|
|
56
56
|
file.write("FROM python:3.11-slim\n")
|
|
57
57
|
file.write("WORKDIR /app\n")
|
|
58
58
|
file.write("COPY . .\n")
|
|
59
|
-
file.write("RUN pip install flask praisonai==0.0.
|
|
59
|
+
file.write("RUN pip install flask praisonai==0.0.53 gunicorn markdown\n")
|
|
60
60
|
file.write("EXPOSE 8080\n")
|
|
61
61
|
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
|
62
62
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import fnmatch
|
|
3
|
+
import re
|
|
4
|
+
import yaml
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
# Set up logging
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
log_level = os.getenv("LOGLEVEL", "INFO").upper()
|
|
11
|
+
logger.handlers = []
|
|
12
|
+
|
|
13
|
+
# Set up logging to console
|
|
14
|
+
console_handler = logging.StreamHandler()
|
|
15
|
+
console_handler.setLevel(log_level)
|
|
16
|
+
console_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
17
|
+
console_handler.setFormatter(console_formatter)
|
|
18
|
+
logger.addHandler(console_handler)
|
|
19
|
+
|
|
20
|
+
# Set the logging level for the logger
|
|
21
|
+
logger.setLevel(log_level)
|
|
22
|
+
|
|
23
|
+
class ContextGatherer:
|
|
24
|
+
def __init__(self, directory='.', output_file='context.txt',
|
|
25
|
+
relevant_extensions=None, max_file_size=1_000_000, max_tokens=900000):
|
|
26
|
+
self.directory = directory
|
|
27
|
+
self.output_file = output_file
|
|
28
|
+
self.relevant_extensions = relevant_extensions or [
|
|
29
|
+
'.py', '.js', '.ts', '.java', '.rb', '.php', '.pl', '.pm', '.c', '.h',
|
|
30
|
+
'.cpp', '.hpp', '.cs', '.vb', '.swift', '.kt', '.m', '.mm', '.go', '.rs',
|
|
31
|
+
'.hs', '.r', '.lua', '.sh', '.bat', '.clj', '.scala', '.erl', '.ex',
|
|
32
|
+
'.ml', '.fs', '.groovy', '.jsm', '.jsx', '.tsx', '.yaml'
|
|
33
|
+
]
|
|
34
|
+
self.max_file_size = max_file_size
|
|
35
|
+
self.max_tokens = int(os.getenv("PRAISONAI_MAX_TOKENS", max_tokens))
|
|
36
|
+
self.ignore_patterns = self.get_ignore_patterns()
|
|
37
|
+
|
|
38
|
+
def get_ignore_patterns(self):
|
|
39
|
+
"""
|
|
40
|
+
Loads ignore patterns from various sources, prioritizing them in
|
|
41
|
+
the following order:
|
|
42
|
+
1. .praisonignore
|
|
43
|
+
2. settings.yaml (under code.ignore_files)
|
|
44
|
+
3. PRAISONAI_IGNORE_FILES environment variable
|
|
45
|
+
4. .gitignore
|
|
46
|
+
5. Default patterns
|
|
47
|
+
"""
|
|
48
|
+
ignore_patterns = []
|
|
49
|
+
|
|
50
|
+
def load_from_file(filepath):
|
|
51
|
+
if os.path.exists(filepath):
|
|
52
|
+
with open(filepath, 'r') as f:
|
|
53
|
+
ignore_patterns.extend(
|
|
54
|
+
line.strip() for line in f
|
|
55
|
+
if line.strip() and not line.startswith('#')
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# 1. Load from .praisonignore
|
|
59
|
+
load_from_file(os.path.join(self.directory, '.praisonignore'))
|
|
60
|
+
|
|
61
|
+
# 2. Load from settings.yaml
|
|
62
|
+
settings_path = os.path.join(self.directory, 'settings.yaml')
|
|
63
|
+
if os.path.exists(settings_path):
|
|
64
|
+
with open(settings_path, 'r') as f:
|
|
65
|
+
settings = yaml.safe_load(f)
|
|
66
|
+
if 'code' in settings and 'ignore_files' in settings['code']:
|
|
67
|
+
ignore_patterns.extend(settings['code']['ignore_files'])
|
|
68
|
+
|
|
69
|
+
# 3. Load from environment variable
|
|
70
|
+
ignore_files_env = os.getenv("PRAISONAI_IGNORE_FILES")
|
|
71
|
+
if ignore_files_env:
|
|
72
|
+
ignore_patterns.extend(ignore_files_env.split(","))
|
|
73
|
+
|
|
74
|
+
# 4. Load from .gitignore
|
|
75
|
+
load_from_file(os.path.join(self.directory, '.gitignore'))
|
|
76
|
+
|
|
77
|
+
# 5. Default patterns (only if no patterns loaded from above sources)
|
|
78
|
+
if not ignore_patterns:
|
|
79
|
+
ignore_patterns = [
|
|
80
|
+
".*", "*.pyc", "__pycache__", ".git", ".gitignore", ".vscode",
|
|
81
|
+
".idea", ".DS_Store", "*.lock", "*.pyc", ".env", "docs", "tests",
|
|
82
|
+
"test", "tmp", "temp", "*.txt", "*.md", "*.json", "*.csv", "*.tsv",
|
|
83
|
+
"public", "*.sql", "*.sqlite", "*.db", "*.db3", "*.sqlite3",
|
|
84
|
+
"*.log", "*.zip", "*.gz", "*.tar", "*.rar", "*.7z", "*.pdf",
|
|
85
|
+
"*.jpg", "*.jpeg", "*.png", "*.gif", "*.svg", "cookbooks",
|
|
86
|
+
"assets", "__pycache__", "dist", "build", "node_modules", "venv"
|
|
87
|
+
]
|
|
88
|
+
logger.debug(f"Using default ignore patterns: {ignore_patterns}")
|
|
89
|
+
|
|
90
|
+
# Modify patterns to match directories and add leading '*' if necessary
|
|
91
|
+
modified_ignore_patterns = [
|
|
92
|
+
'*' + pattern if not pattern.startswith('.') and not pattern.startswith('*') else pattern
|
|
93
|
+
for pattern in ignore_patterns
|
|
94
|
+
]
|
|
95
|
+
logger.debug(f"Final ignore patterns: {modified_ignore_patterns}")
|
|
96
|
+
return modified_ignore_patterns
|
|
97
|
+
|
|
98
|
+
def should_ignore(self, file_path):
|
|
99
|
+
"""
|
|
100
|
+
Check if a file or directory should be ignored based on patterns.
|
|
101
|
+
Handles both file names and directory names for more comprehensive filtering.
|
|
102
|
+
"""
|
|
103
|
+
relative_path = os.path.relpath(file_path, self.directory)
|
|
104
|
+
if relative_path.startswith('.'):
|
|
105
|
+
return True
|
|
106
|
+
for pattern in self.ignore_patterns:
|
|
107
|
+
if fnmatch.fnmatch(relative_path, pattern) or \
|
|
108
|
+
fnmatch.fnmatch(os.path.basename(file_path), pattern):
|
|
109
|
+
return True
|
|
110
|
+
return False
|
|
111
|
+
|
|
112
|
+
def is_relevant_file(self, file_path):
|
|
113
|
+
"""Determine if a file is relevant for the context."""
|
|
114
|
+
return os.path.isfile(file_path) and \
|
|
115
|
+
os.path.getsize(file_path) <= self.max_file_size and \
|
|
116
|
+
any(file_path.endswith(ext) for ext in self.relevant_extensions)
|
|
117
|
+
|
|
118
|
+
def gather_context(self):
|
|
119
|
+
"""Gather context from relevant files, respecting ignore patterns."""
|
|
120
|
+
context = []
|
|
121
|
+
total_files = 0
|
|
122
|
+
processed_files = 0
|
|
123
|
+
|
|
124
|
+
for root, dirs, files in os.walk(self.directory):
|
|
125
|
+
total_files += len(files)
|
|
126
|
+
dirs[:] = [d for d in dirs if not self.should_ignore(os.path.join(root, d))]
|
|
127
|
+
for file in files:
|
|
128
|
+
file_path = os.path.join(root, file)
|
|
129
|
+
if not self.should_ignore(file_path) and self.is_relevant_file(file_path):
|
|
130
|
+
try:
|
|
131
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
132
|
+
content = f.read()
|
|
133
|
+
context.append(f"File: {file_path}\n\n{content}\n\n{'='*50}\n")
|
|
134
|
+
except Exception as e:
|
|
135
|
+
logger.error(f"Error reading {file_path}: {e}")
|
|
136
|
+
processed_files += 1
|
|
137
|
+
print(f"\rProcessed {processed_files}/{total_files} files", end="", flush=True)
|
|
138
|
+
print() # New line after progress indicator
|
|
139
|
+
return '\n'.join(context)
|
|
140
|
+
|
|
141
|
+
def count_tokens(self, text):
|
|
142
|
+
"""Count tokens using a simple whitespace-based tokenizer."""
|
|
143
|
+
return len(text.split())
|
|
144
|
+
|
|
145
|
+
def truncate_context(self, context):
|
|
146
|
+
"""Truncate context to stay within the token limit."""
|
|
147
|
+
tokens = context.split()
|
|
148
|
+
if len(tokens) > self.max_tokens:
|
|
149
|
+
truncated_context = ' '.join(tokens[:self.max_tokens])
|
|
150
|
+
logger.warning("Context truncated due to token limit.")
|
|
151
|
+
return truncated_context
|
|
152
|
+
return context
|
|
153
|
+
|
|
154
|
+
def save_context(self, context):
|
|
155
|
+
"""Save the gathered context to a file."""
|
|
156
|
+
with open(self.output_file, 'w', encoding='utf-8') as f:
|
|
157
|
+
f.write(context)
|
|
158
|
+
|
|
159
|
+
def get_context_tree(self):
|
|
160
|
+
"""Generate a formatted tree structure of included files and folders."""
|
|
161
|
+
tree = []
|
|
162
|
+
start_dir = Path(self.directory)
|
|
163
|
+
|
|
164
|
+
def add_to_tree(path, prefix=''):
|
|
165
|
+
contents = sorted(path.iterdir())
|
|
166
|
+
pointers = [('└── ' if i == len(contents) - 1 else '├── ') for i in range(len(contents))]
|
|
167
|
+
for pointer, item in zip(pointers, contents):
|
|
168
|
+
# Use should_ignore for consistency
|
|
169
|
+
if self.should_ignore(item):
|
|
170
|
+
continue
|
|
171
|
+
|
|
172
|
+
rel_path = item.relative_to(start_dir)
|
|
173
|
+
tree.append(f"{prefix}{pointer}{rel_path}")
|
|
174
|
+
|
|
175
|
+
if item.is_dir():
|
|
176
|
+
add_to_tree(item, prefix + (' ' if pointer == '└── ' else '│ '))
|
|
177
|
+
|
|
178
|
+
add_to_tree(start_dir)
|
|
179
|
+
return '\n'.join(tree)
|
|
180
|
+
|
|
181
|
+
def run(self):
|
|
182
|
+
"""Execute the context gathering, truncation, and reporting."""
|
|
183
|
+
context = self.gather_context()
|
|
184
|
+
context = self.truncate_context(context)
|
|
185
|
+
token_count = self.count_tokens(context)
|
|
186
|
+
print(f"Context gathered successfully.")
|
|
187
|
+
print(f"Total number of tokens (estimated): {token_count}")
|
|
188
|
+
# self.save_context(context)
|
|
189
|
+
context_tree = self.get_context_tree()
|
|
190
|
+
logger.debug(f"Context tree:\n{context_tree}")
|
|
191
|
+
return context, token_count, context_tree
|
|
192
|
+
|
|
193
|
+
def main():
|
|
194
|
+
gatherer = ContextGatherer()
|
|
195
|
+
context, token_count, context_tree = gatherer.run()
|
|
196
|
+
print(f"\nThe context contains approximately {token_count} tokens.")
|
|
197
|
+
print("First 500 characters of context:")
|
|
198
|
+
print(context[:500] + "...")
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "PraisonAI"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.53"
|
|
4
4
|
description = "PraisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration."
|
|
5
5
|
authors = ["Mervin Praison"]
|
|
6
6
|
license = ""
|
|
@@ -31,6 +31,7 @@ langchain-openai = {version = ">=0.1.7", optional = true}
|
|
|
31
31
|
langchain-cohere = {version = ">=0.1.4", optional = true}
|
|
32
32
|
litellm = {version = ">=1.41.8", optional = true}
|
|
33
33
|
aiosqlite= {version = ">=0.20.0", optional = true}
|
|
34
|
+
greenlet = {version = ">=3.0.3", optional = true}
|
|
34
35
|
|
|
35
36
|
[tool.poetry.group.docs.dependencies]
|
|
36
37
|
mkdocs = "*"
|
|
@@ -79,6 +80,7 @@ langchain-openai = ">=0.1.7"
|
|
|
79
80
|
langchain-cohere = ">=0.1.4"
|
|
80
81
|
litellm = ">=1.41.8"
|
|
81
82
|
aiosqlite = ">=0.20.0"
|
|
83
|
+
greenlet = ">=3.0.3"
|
|
82
84
|
|
|
83
85
|
[build-system]
|
|
84
86
|
requires = ["poetry-core"]
|
|
@@ -98,4 +100,4 @@ openai = ["langchain-openai"]
|
|
|
98
100
|
anthropic = ["langchain-anthropic"]
|
|
99
101
|
cohere = ["langchain-cohere"]
|
|
100
102
|
chat = ["chainlit", "litellm"]
|
|
101
|
-
code = ["chainlit", "litellm", "aiosqlite"]
|
|
103
|
+
code = ["chainlit", "litellm", "aiosqlite", "greenlet"]
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import fnmatch
|
|
3
|
-
import re
|
|
4
|
-
import yaml
|
|
5
|
-
import logging
|
|
6
|
-
# Set up logging
|
|
7
|
-
logger = logging.getLogger(__name__)
|
|
8
|
-
log_level = os.getenv("LOGLEVEL", "INFO").upper()
|
|
9
|
-
logger.handlers = []
|
|
10
|
-
|
|
11
|
-
# Set up logging to console
|
|
12
|
-
console_handler = logging.StreamHandler()
|
|
13
|
-
console_handler.setLevel(log_level)
|
|
14
|
-
console_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
15
|
-
console_handler.setFormatter(console_formatter)
|
|
16
|
-
logger.addHandler(console_handler)
|
|
17
|
-
|
|
18
|
-
# Set the logging level for the logger
|
|
19
|
-
logger.setLevel(log_level)
|
|
20
|
-
|
|
21
|
-
class ContextGatherer:
|
|
22
|
-
def __init__(self, directory='.', output_file='context.txt',
|
|
23
|
-
relevant_extensions=None, max_file_size=1_000_000, max_tokens=128000):
|
|
24
|
-
self.directory = directory
|
|
25
|
-
self.output_file = output_file
|
|
26
|
-
self.relevant_extensions = relevant_extensions or ['.py']
|
|
27
|
-
self.max_file_size = max_file_size
|
|
28
|
-
self.max_tokens = int(os.getenv("PRAISONAI_MAX_TOKENS", max_tokens))
|
|
29
|
-
self.ignore_patterns = self.get_ignore_patterns()
|
|
30
|
-
|
|
31
|
-
def get_ignore_patterns(self):
|
|
32
|
-
"""Read .gitignore file and return ignore patterns."""
|
|
33
|
-
|
|
34
|
-
settings_path = os.path.join(self.directory, 'settings.yaml')
|
|
35
|
-
if os.path.exists(settings_path):
|
|
36
|
-
with open(settings_path, 'r') as f:
|
|
37
|
-
settings = yaml.safe_load(f)
|
|
38
|
-
if 'code' in settings and 'ignore_files' in settings['code']:
|
|
39
|
-
logger.debug(f"Ignored settings.yaml files: {settings['code']['ignore_files']}")
|
|
40
|
-
return settings['code']['ignore_files']
|
|
41
|
-
|
|
42
|
-
# If settings.yaml doesn't exist, get from env variable
|
|
43
|
-
ignore_files_env = os.getenv("PRAISONAI_IGNORE_FILES")
|
|
44
|
-
if ignore_files_env:
|
|
45
|
-
logger.debug(f"Ignored PRAISONAI_IGNORE_FILES ENV files: {ignore_files_env}")
|
|
46
|
-
return ignore_files_env.split(",")
|
|
47
|
-
|
|
48
|
-
default_patterns = [".*", "*.pyc", "__pycache__", ".git", ".gitignore", ".vscode",
|
|
49
|
-
".idea", ".DS_Store", "*.lock", "*.pyc", ".env",
|
|
50
|
-
"docs", "tests", "test", "tmp", "temp",
|
|
51
|
-
"*.txt", "*.md", "*.json", "*.csv", "*.tsv","public",
|
|
52
|
-
"*.sql", "*.sqlite", "*.db", "*.db3", "*.sqlite3", "*.log", "*.zip", "*.gz",
|
|
53
|
-
"*.tar", "*.rar", "*.7z", "*.pdf", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.svg",
|
|
54
|
-
"cookbooks", "assets", "__pycache__", "dist", "build", "node_modules", "venv",]
|
|
55
|
-
gitignore_path = os.path.join(self.directory, '.gitignore')
|
|
56
|
-
if os.path.exists(gitignore_path):
|
|
57
|
-
with open(gitignore_path, 'r') as f:
|
|
58
|
-
gitignore_patterns = [line.strip() for line in f if line.strip() and not line.startswith('#')]
|
|
59
|
-
logger.debug(f"Ignored gitignore and default files: {ignore_files_env}")
|
|
60
|
-
return list(set(default_patterns + gitignore_patterns))
|
|
61
|
-
return default_patterns
|
|
62
|
-
|
|
63
|
-
def should_ignore(self, file_path):
|
|
64
|
-
"""Check if a file should be ignored based on patterns."""
|
|
65
|
-
relative_path = os.path.relpath(file_path, self.directory)
|
|
66
|
-
if relative_path.startswith('.'):
|
|
67
|
-
return True
|
|
68
|
-
for pattern in self.ignore_patterns:
|
|
69
|
-
if fnmatch.fnmatch(relative_path, pattern):
|
|
70
|
-
return True
|
|
71
|
-
return False
|
|
72
|
-
|
|
73
|
-
def is_relevant_file(self, file_path):
|
|
74
|
-
"""Determine if a file is relevant for the context."""
|
|
75
|
-
if os.path.getsize(file_path) > self.max_file_size:
|
|
76
|
-
return False
|
|
77
|
-
return any(file_path.endswith(ext) for ext in self.relevant_extensions)
|
|
78
|
-
|
|
79
|
-
def gather_context(self):
|
|
80
|
-
"""Gather context from relevant files in the directory."""
|
|
81
|
-
context = []
|
|
82
|
-
total_files = sum(len(files) for _, _, files in os.walk(self.directory))
|
|
83
|
-
processed_files = 0
|
|
84
|
-
|
|
85
|
-
for root, dirs, files in os.walk(self.directory):
|
|
86
|
-
dirs[:] = [d for d in dirs if not self.should_ignore(os.path.join(root, d))]
|
|
87
|
-
for file in files:
|
|
88
|
-
file_path = os.path.join(root, file)
|
|
89
|
-
if not self.should_ignore(file_path) and self.is_relevant_file(file_path):
|
|
90
|
-
try:
|
|
91
|
-
with open(file_path, 'r', encoding='utf-8') as f:
|
|
92
|
-
content = f.read()
|
|
93
|
-
context.append(f"File: {file_path}\n\n{content}\n\n{'='*50}\n")
|
|
94
|
-
except Exception as e:
|
|
95
|
-
print(f"Error reading {file_path}: {e}")
|
|
96
|
-
processed_files += 1
|
|
97
|
-
print(f"\rProcessed {processed_files}/{total_files} files", end="", flush=True)
|
|
98
|
-
print() # New line after progress indicator
|
|
99
|
-
return '\n'.join(context)
|
|
100
|
-
|
|
101
|
-
def count_tokens(self, text):
|
|
102
|
-
"""Count the number of tokens in the given text using a simple tokenizer."""
|
|
103
|
-
# Split on whitespace and punctuation
|
|
104
|
-
tokens = re.findall(r'\b\w+\b|[^\w\s]', text)
|
|
105
|
-
return len(tokens)
|
|
106
|
-
|
|
107
|
-
def truncate_context(self, context):
|
|
108
|
-
"""Truncate context to fit within the specified token limit."""
|
|
109
|
-
tokens = re.findall(r'\b\w+\b|[^\w\s]', context)
|
|
110
|
-
if len(tokens) > self.max_tokens:
|
|
111
|
-
truncated_tokens = tokens[:self.max_tokens]
|
|
112
|
-
return ' '.join(truncated_tokens)
|
|
113
|
-
return context
|
|
114
|
-
|
|
115
|
-
def save_context(self, context):
|
|
116
|
-
"""Save the gathered context to a file."""
|
|
117
|
-
with open(self.output_file, 'w', encoding='utf-8') as f:
|
|
118
|
-
f.write(context)
|
|
119
|
-
|
|
120
|
-
def get_context_tree(self):
|
|
121
|
-
"""Generate a formatted tree structure of the folder, including only relevant files."""
|
|
122
|
-
tree = []
|
|
123
|
-
start_dir = os.path.abspath(self.directory)
|
|
124
|
-
|
|
125
|
-
def add_to_tree(path, prefix=''):
|
|
126
|
-
contents = sorted(os.listdir(path))
|
|
127
|
-
pointers = [('└── ' if i == len(contents) - 1 else '├── ') for i in range(len(contents))]
|
|
128
|
-
for pointer, name in zip(pointers, contents):
|
|
129
|
-
full_path = os.path.join(path, name)
|
|
130
|
-
if self.should_ignore(full_path):
|
|
131
|
-
continue
|
|
132
|
-
|
|
133
|
-
rel_path = os.path.relpath(full_path, start_dir)
|
|
134
|
-
tree.append(f"{prefix}{pointer}{name}")
|
|
135
|
-
|
|
136
|
-
if os.path.isdir(full_path):
|
|
137
|
-
add_to_tree(full_path, prefix + (' ' if pointer == '└── ' else '│ '))
|
|
138
|
-
elif self.is_relevant_file(full_path):
|
|
139
|
-
continue # We've already added the file to the tree
|
|
140
|
-
|
|
141
|
-
add_to_tree(start_dir)
|
|
142
|
-
return '\n'.join(tree)
|
|
143
|
-
|
|
144
|
-
def run(self):
|
|
145
|
-
"""Run the context gathering process and return the context and token count."""
|
|
146
|
-
context = self.gather_context()
|
|
147
|
-
context = self.truncate_context(context)
|
|
148
|
-
token_count = self.count_tokens(context)
|
|
149
|
-
print(f"Context gathered successfully.")
|
|
150
|
-
print(f"Total number of tokens (estimated): {token_count}")
|
|
151
|
-
# self.save_context(context)
|
|
152
|
-
context_tree = self.get_context_tree()
|
|
153
|
-
print("\nContext Tree Structure:")
|
|
154
|
-
print(context_tree)
|
|
155
|
-
|
|
156
|
-
return context, token_count, context_tree
|
|
157
|
-
|
|
158
|
-
def main():
|
|
159
|
-
gatherer = ContextGatherer(
|
|
160
|
-
directory='.',
|
|
161
|
-
output_file='context.txt',
|
|
162
|
-
relevant_extensions=['.py'],
|
|
163
|
-
max_file_size=500_000, # 500KB
|
|
164
|
-
max_tokens=60000
|
|
165
|
-
)
|
|
166
|
-
context, token_count, context_tree = gatherer.run()
|
|
167
|
-
print(f"\nThe context contains approximately {token_count} tokens.")
|
|
168
|
-
print("First 500 characters of context:")
|
|
169
|
-
print(context[:500] + "...")
|
|
170
|
-
|
|
171
|
-
if __name__ == "__main__":
|
|
172
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|