PraisonAI 0.0.59rc9__cp312-cp312-manylinux_2_35_x86_64.whl → 0.0.61__cp312-cp312-manylinux_2_35_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

praisonai/cli.py CHANGED
@@ -12,6 +12,7 @@ import argparse
12
12
  from .auto import AutoGenerator
13
13
  from .agents_generator import AgentsGenerator
14
14
  from .inbuilt_tools import *
15
+ from .inc.config import generate_config
15
16
  import shutil
16
17
  import subprocess
17
18
  import logging
@@ -130,17 +131,26 @@ class PraisonAI:
130
131
 
131
132
  if args.agent_file == 'train':
132
133
  package_root = os.path.dirname(os.path.abspath(__file__))
133
- config_yaml_source = os.path.join(package_root, 'setup', 'config.yaml')
134
134
  config_yaml_destination = os.path.join(os.getcwd(), 'config.yaml')
135
135
 
136
- if not os.path.exists(config_yaml_destination):
137
- try:
138
- shutil.copyfile(config_yaml_source, config_yaml_destination)
139
- print("config.yaml copied to the current directory.")
140
- except FileExistsError:
141
- print("config.yaml already exists in the current directory. Skipping copy.")
142
- else:
143
- print("config.yaml already exists in the current directory. Skipping copy.")
136
+ # Create config.yaml only if it doesn't exist or --model or --dataset is provided
137
+ if not os.path.exists(config_yaml_destination) or args.model or args.dataset:
138
+ config = generate_config(
139
+ model_name=args.model,
140
+ hf_model_name=args.hf,
141
+ ollama_model_name=args.ollama,
142
+ dataset=[{
143
+ "name": args.dataset
144
+ }]
145
+ )
146
+ with open('config.yaml', 'w') as f:
147
+ yaml.dump(config, f, default_flow_style=False, indent=2)
148
+
149
+ # Overwrite huggingface_save and ollama_save if --hf or --ollama are provided
150
+ if args.hf:
151
+ config["huggingface_save"] = "true"
152
+ if args.ollama:
153
+ config["ollama_save"] = "true"
144
154
 
145
155
  if 'init' in sys.argv:
146
156
  from praisonai.setup.setup_conda_env import main as setup_conda_main
@@ -150,12 +160,12 @@ class PraisonAI:
150
160
 
151
161
  try:
152
162
  result = subprocess.check_output(['conda', 'env', 'list'])
153
- if 'prasion_env' in result.decode('utf-8'):
154
- print("Conda environment 'prasion_env' found.")
163
+ if 'praison_env' in result.decode('utf-8'):
164
+ print("Conda environment 'praison_env' found.")
155
165
  else:
156
166
  raise subprocess.CalledProcessError(1, 'grep')
157
167
  except subprocess.CalledProcessError:
158
- print("Conda environment 'prasion_env' not found. Setting it up...")
168
+ print("Conda environment 'praison_env' not found. Setting it up...")
159
169
  from praisonai.setup.setup_conda_env import main as setup_conda_main
160
170
  setup_conda_main()
161
171
  print("All packages installed.")
@@ -167,7 +177,7 @@ class PraisonAI:
167
177
  env = os.environ.copy()
168
178
  env['PYTHONUNBUFFERED'] = '1'
169
179
 
170
- stream_subprocess(['conda', 'run', '--no-capture-output', '--name', 'prasion_env', 'python', '-u', train_script_path, 'train'] + train_args, env=env)
180
+ stream_subprocess(['conda', 'run', '--no-capture-output', '--name', 'praison_env', 'python', '-u', train_script_path, 'train'], env=env)
171
181
  return
172
182
 
173
183
  invocation_cmd = "praisonai"
@@ -240,7 +250,11 @@ class PraisonAI:
240
250
  parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
241
251
  parser.add_argument("--init", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
242
252
  parser.add_argument("agent_file", nargs="?", help="Specify the agent file")
243
- parser.add_argument("--deploy", action="store_true", help="Deploy the application") # New argument
253
+ parser.add_argument("--deploy", action="store_true", help="Deploy the application")
254
+ parser.add_argument("--model", type=str, help="Model name")
255
+ parser.add_argument("--hf", type=str, help="Hugging Face model name")
256
+ parser.add_argument("--ollama", type=str, help="Ollama model name")
257
+ parser.add_argument("--dataset", type=str, help="Dataset name for training", default="yahma/alpaca-cleaned")
244
258
  args, unknown_args = parser.parse_known_args()
245
259
 
246
260
  if unknown_args and unknown_args[0] == '-b' and unknown_args[1] == 'api:app':
praisonai/deploy.py CHANGED
@@ -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.59rc9 gunicorn markdown\n")
59
+ file.write("RUN pip install flask praisonai==0.0.61 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,96 @@
1
+ def generate_config(
2
+ ollama_save=None,
3
+ huggingface_save=None,
4
+ train=None,
5
+ model_name=None,
6
+ hf_model_name=None,
7
+ ollama_model_name=None,
8
+ model_parameters=None,
9
+ max_seq_length=None,
10
+ load_in_4bit=None,
11
+ lora_r=None,
12
+ lora_target_modules=None,
13
+ lora_alpha=None,
14
+ lora_dropout=None,
15
+ lora_bias=None,
16
+ use_gradient_checkpointing=None,
17
+ random_state=None,
18
+ use_rslora=None,
19
+ loftq_config=None,
20
+ dataset=None,
21
+ dataset_text_field=None,
22
+ dataset_num_proc=None,
23
+ packing=None,
24
+ per_device_train_batch_size=None,
25
+ gradient_accumulation_steps=None,
26
+ warmup_steps=None,
27
+ num_train_epochs=None,
28
+ max_steps=None,
29
+ learning_rate=None,
30
+ logging_steps=None,
31
+ optim=None,
32
+ weight_decay=None,
33
+ lr_scheduler_type=None,
34
+ seed=None,
35
+ output_dir=None,
36
+ quantization_method=None
37
+ ):
38
+ """Generates the configuration for PraisonAI with dynamic overrides."""
39
+
40
+ config = {
41
+ "ollama_save": ollama_save or "true",
42
+ "huggingface_save": huggingface_save or "true",
43
+ "train": train or "true",
44
+
45
+ "model_name": model_name or "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit",
46
+ "hf_model_name": hf_model_name or "mervinpraison/llama-3.1-tamilan-8B-test",
47
+ "ollama_model": ollama_model_name or "mervinpraison/llama3.1-tamilan-test",
48
+ "model_parameters": model_parameters or "8b",
49
+
50
+ "dataset": dataset or [
51
+ {
52
+ "name": "yahma/alpaca-cleaned",
53
+ "split_type": "train",
54
+ "processing_func": "format_prompts",
55
+ "rename": {"input": "input", "output": "output", "instruction": "instruction"},
56
+ "filter_data": False,
57
+ "filter_column_value": "id",
58
+ "filter_value": "alpaca",
59
+ "num_samples": 20000
60
+ }
61
+ ],
62
+
63
+ "dataset_text_field": dataset_text_field or "text",
64
+ "dataset_num_proc": dataset_num_proc or 2,
65
+ "packing": packing or False,
66
+
67
+ "max_seq_length": max_seq_length or 2048,
68
+ "load_in_4bit": load_in_4bit or True,
69
+ "lora_r": lora_r or 16,
70
+ "lora_target_modules": lora_target_modules or [
71
+ "q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"
72
+ ],
73
+ "lora_alpha": lora_alpha or 16,
74
+ "lora_dropout": lora_dropout or 0,
75
+ "lora_bias": lora_bias or "none",
76
+ "use_gradient_checkpointing": use_gradient_checkpointing or "unsloth",
77
+ "random_state": random_state or 3407,
78
+ "use_rslora": use_rslora or False,
79
+ "loftq_config": loftq_config or None,
80
+
81
+ "per_device_train_batch_size": per_device_train_batch_size or 2,
82
+ "gradient_accumulation_steps": gradient_accumulation_steps or 2,
83
+ "warmup_steps": warmup_steps or 5,
84
+ "num_train_epochs": num_train_epochs or 1,
85
+ "max_steps": max_steps or 10,
86
+ "learning_rate": learning_rate or 2.0e-4,
87
+ "logging_steps": logging_steps or 1,
88
+ "optim": optim or "adamw_8bit",
89
+ "weight_decay": weight_decay or 0.01,
90
+ "lr_scheduler_type": lr_scheduler_type or "linear",
91
+ "seed": seed or 3407,
92
+ "output_dir": output_dir or "outputs",
93
+
94
+ "quantization_method": quantization_method or ["q4_k_m"]
95
+ }
96
+ return config
@@ -1,9 +1,16 @@
1
+ ollama_save: "true"
2
+ huggingface_save: "true"
3
+ train: "true"
4
+
1
5
  model_name: "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit"
2
6
  hf_model_name: "mervinpraison/llama-3.1-tamilan-8B-test"
7
+ ollama_model: "mervinpraison/llama3.1-tamilan-test"
8
+ model_parameters: "8b"
9
+
3
10
  max_seq_length: 2048
4
11
  load_in_4bit: true
5
12
  lora_r: 16
6
- lora_target_modules:
13
+ lora_target_modules:
7
14
  - "q_proj"
8
15
  - "k_proj"
9
16
  - "v_proj"
@@ -50,7 +57,4 @@ seed: 3407
50
57
  output_dir: "outputs"
51
58
 
52
59
  quantization_method:
53
- - "q4_k_m"
54
-
55
- ollama_model: "llama3.1-tamilan-test"
56
- model_parameters: "8b"
60
+ - "q4_k_m"
@@ -33,7 +33,7 @@ else
33
33
  fi
34
34
 
35
35
  # Create and activate the Conda environment
36
- ENV_NAME="prasion_env"
36
+ ENV_NAME="praison_env"
37
37
  if conda info --envs | grep -q $ENV_NAME; then
38
38
  echo "Environment $ENV_NAME already exists. Recreating..."
39
39
  conda env remove -y -n $ENV_NAME # Remove existing environment
praisonai/train.py CHANGED
@@ -142,6 +142,8 @@ class train:
142
142
  ),
143
143
  )
144
144
  trainer.train()
145
+ self.model.save_pretrained("lora_model") # Local saving
146
+ self.tokenizer.save_pretrained("lora_model")
145
147
 
146
148
  def inference(self, instruction, input_text):
147
149
  FastLanguageModel.for_inference(self.model)
@@ -158,6 +160,17 @@ class train:
158
160
  inputs = self.tokenizer([alpaca_prompt.format(instruction, input_text, "")], return_tensors="pt").to("cuda")
159
161
  outputs = self.model.generate(**inputs, max_new_tokens=64, use_cache=True)
160
162
  print(self.tokenizer.batch_decode(outputs))
163
+
164
+ def load_model(self):
165
+ """Loads the model and tokenizer using the FastLanguageModel library."""
166
+ from unsloth import FastLanguageModel
167
+ model, tokenizer = FastLanguageModel.from_pretrained(
168
+ model_name=self.config["output_dir"],
169
+ max_seq_length=2048,
170
+ dtype=None,
171
+ load_in_4bit=self.config["load_in_4bit"],
172
+ )
173
+ return model, tokenizer
161
174
 
162
175
  def save_model_merged(self):
163
176
  if os.path.exists(self.config["hf_model_name"]):
@@ -176,9 +189,22 @@ class train:
176
189
  quantization_method=self.config["quantization_method"],
177
190
  token=os.getenv('HF_TOKEN')
178
191
  )
192
+
193
+ def save_model_gguf(self):
194
+ self.model.save_pretrained_gguf(
195
+ self.config["hf_model_name"],
196
+ self.tokenizer,
197
+ quantization_method="q4_k_m"
198
+ )
179
199
 
180
200
  def prepare_modelfile_content(self):
181
201
  output_model = self.config["hf_model_name"]
202
+ gguf_path = f"{output_model}/unsloth.Q4_K_M.gguf"
203
+
204
+ # Check if the GGUF file exists. If not, generate it ## TODO Multiple Quantisation other than Q4_K_M.gguf
205
+ if not os.path.exists(gguf_path):
206
+ self.model, self.tokenizer = self.load_model()
207
+ self.save_model_gguf()
182
208
  return f"""FROM {output_model}/unsloth.Q4_K_M.gguf
183
209
 
184
210
  TEMPLATE \"\"\"Below are some instructions that describe some tasks. Write responses that appropriately complete each request.{{{{ if .Prompt }}}}
@@ -210,11 +236,28 @@ PARAMETER stop "<|reserved_special_token_"
210
236
  self.check_gpu()
211
237
  self.check_ram()
212
238
  # self.install_packages()
213
- self.prepare_model()
214
- self.train_model()
215
- self.save_model_merged()
216
- self.push_model_gguf()
217
- self.create_and_push_ollama_model()
239
+ if self.config.get("train", "true").lower() == "true":
240
+ self.prepare_model()
241
+ self.train_model()
242
+
243
+ if self.config.get("huggingface_save", "true").lower() == "true":
244
+ # self.model, self.tokenizer = self.load_model()
245
+ self.save_model_merged()
246
+
247
+ if self.config.get("huggingface_save_gguf", "true").lower() == "true":
248
+ # self.model, self.tokenizer = self.load_model()
249
+ self.push_model_gguf()
250
+
251
+ # if self.config.get("save_gguf", "true").lower() == "true": ## TODO
252
+ # self.model, self.tokenizer = self.load_model()
253
+ # self.save_model_gguf()
254
+
255
+ # if self.config.get("save_merged", "true").lower() == "true": ## TODO
256
+ # self.model, self.tokenizer = self.load_model()
257
+ # self.save_model_merged()
258
+
259
+ if self.config.get("ollama_save", "true").lower() == "true":
260
+ self.create_and_push_ollama_model()
218
261
 
219
262
 
220
263
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PraisonAI
3
- Version: 0.0.59rc9
3
+ Version: 0.0.61
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
@@ -3,11 +3,12 @@ praisonai/__main__.py,sha256=MVgsjMThjBexHt4nhd760JCqvP4x0IQcwo8kULOK4FQ,144
3
3
  praisonai/agents_generator.py,sha256=8d1WRbubvEkBrW1HZ7_xnGyqgJi0yxmXa3MgTIqef1c,19127
4
4
  praisonai/auto.py,sha256=9spTXqj47Hmmqv5QHRYE_RzSVHH_KoPbaZjskUj2UcE,7895
5
5
  praisonai/chainlit_ui.py,sha256=bNR7s509lp0I9JlJNvwCZRUZosC64qdvlFCt8NmFamQ,12216
6
- praisonai/cli.py,sha256=WQf6NG1xEcyE9ySR4ahSiVDxCkedGV6A0Yaf78uYXQ0,17411
7
- praisonai/deploy.py,sha256=_jT6RcTHzxeWKtizSyaGmfE48FKbvw___CHn6jOuWnc,6031
6
+ praisonai/cli.py,sha256=ZDQF9OXgaquu_89cLc-jsx5D9zWxYg4ChPhlVv66drk,18047
7
+ praisonai/deploy.py,sha256=JQ8FsfDYeZ310dSmOAHGfgI0wFjqPK45BrcLrRUOgBw,6028
8
8
  praisonai/inbuilt_tools/__init__.py,sha256=mUKnbL6Gram9c9f2m8wJwEzURBLmPEOcHzwySBH89YA,74
9
9
  praisonai/inbuilt_tools/autogen_tools.py,sha256=svYkM2N7DVFvbiwgoAS7U_MqTOD8rHf8VD3BaFUV5_Y,14907
10
10
  praisonai/inc/__init__.py,sha256=sPDlYBBwdk0VlWzaaM_lG0_LD07lS2HRGvPdxXJFiYg,62
11
+ praisonai/inc/config.py,sha256=up2-841ruK7MCUUT3xkWBA5S6WsY0sFODNfcT6Q4Wms,3333
11
12
  praisonai/inc/models.py,sha256=1kwP9o56AvN8L38x7eeAzudjAvstN0uWu-woQkgxAe4,5449
12
13
  praisonai/public/android-chrome-192x192.png,sha256=ENJEqhDE3XEQViRhKNDezQKRiOiuHOUj5nzRN43fz50,6535
13
14
  praisonai/public/android-chrome-512x512.png,sha256=4txEwB0cJkxFVarRdvFGJZR1DtWJ2h-L_2cUEjBXHAc,15244
@@ -23,12 +24,12 @@ praisonai/public/movie.svg,sha256=aJ2EQ8vXZusVsF2SeuAVxP4RFJzQ14T26ejrGYdBgzk,12
23
24
  praisonai/public/thriller.svg,sha256=2dYY72EcgbEyTxS4QzjAm37Y4srtPWEW4vCMFki98ZI,3163
24
25
  praisonai/setup/__init__.py ,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
26
  praisonai/setup/build.py,sha256=NyTAXQ_UZ8vKo_KwCINp8ctmauZyCMDkw1rys3ay0ec,646
26
- praisonai/setup/config.yaml,sha256=DbfEJyvWTDACScH9XquGGsNYcyudpEwpawd_rgaPN98,1138
27
+ praisonai/setup/config.yaml,sha256=sr_D1RIvv3LQ_eueOMZV0rAUiWTR-n2xuE1RhKK6b34,1211
27
28
  praisonai/setup/post_install.py,sha256=hXukn_7bL64vE582SZcS-9MiZGeJj6hN7upoR1oJ-Bo,576
28
29
  praisonai/setup/setup_conda_env.py,sha256=4QiWrqgEObivzOMwfJgWaCPpUEpB68cQ6lFwVwFoufk,816
29
- praisonai/setup/setup_conda_env.sh,sha256=Ao5kCgIVamCcCKhrXWYELTUr5fQlRQmWwDYjuTxBH6s,2718
30
+ praisonai/setup/setup_conda_env.sh,sha256=te7s0KHsTi7XM-vkNvE0dKC1HeU2tXxqE-sPUScV6fY,2718
30
31
  praisonai/test.py,sha256=OL-wesjA5JTohr8rtr6kWoaS4ImkJg2l0GXJ-dUUfRU,4090
31
- praisonai/train.py,sha256=M2rpBca3k4uQvmoKh-0r_2MTlWLYL7ffKMtlU8hF7k8,9214
32
+ praisonai/train.py,sha256=DvORlrwKOD-2v4r_z84eV3LsfzpNs-WnPKb5cQB3_t4,11071
32
33
  praisonai/ui/chat.py,sha256=B4F1R7qP-0c-elg8WcRsYlr6-FkmHWtdunGIzU7WrDM,9321
33
34
  praisonai/ui/code.py,sha256=GcOr8lNah4AgI2RcIKmgjehzSl-KNu7x6UHrghixeaM,10095
34
35
  praisonai/ui/context.py,sha256=oWO2I_WBZb7kZnuXItf18EJX0ZQv-1nAd8rxhwhuuDU,11871
@@ -40,8 +41,8 @@ praisonai/ui/public/movie.svg,sha256=aJ2EQ8vXZusVsF2SeuAVxP4RFJzQ14T26ejrGYdBgzk
40
41
  praisonai/ui/public/thriller.svg,sha256=2dYY72EcgbEyTxS4QzjAm37Y4srtPWEW4vCMFki98ZI,3163
41
42
  praisonai/ui/sql_alchemy.py,sha256=HsyeRq-G9qbQobHWpTJHHKQiT4FvYw_7iuv-2PNh0IU,27419
42
43
  praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
43
- praisonai-0.0.59rc9.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
44
- praisonai-0.0.59rc9.dist-info/METADATA,sha256=UwVe6VMWXUoygLpeg695CvLu9vK_ikjQ0L-eZ1AE7RM,11151
45
- praisonai-0.0.59rc9.dist-info/WHEEL,sha256=HBsDV7Hj4OTiS1GX6ua7iQXUQTB9UHftbBxr7Q8Xm9c,110
46
- praisonai-0.0.59rc9.dist-info/entry_points.txt,sha256=jB078LEGLY3Ky_indhclomRIVVpXrPSksHjJ-tcBZ-o,133
47
- praisonai-0.0.59rc9.dist-info/RECORD,,
44
+ praisonai-0.0.61.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
45
+ praisonai-0.0.61.dist-info/METADATA,sha256=M-MbTL30aaXFUXZ5M42Gxhcu478_Gl9MfdiZLgnb5jI,11148
46
+ praisonai-0.0.61.dist-info/WHEEL,sha256=HBsDV7Hj4OTiS1GX6ua7iQXUQTB9UHftbBxr7Q8Xm9c,110
47
+ praisonai-0.0.61.dist-info/entry_points.txt,sha256=jB078LEGLY3Ky_indhclomRIVVpXrPSksHjJ-tcBZ-o,133
48
+ praisonai-0.0.61.dist-info/RECORD,,