PraisonAI 2.0.53__cp311-cp311-macosx_15_0_arm64.whl → 2.2.16__cp311-cp311-macosx_15_0_arm64.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/README.md +5 -0
- praisonai/agents_generator.py +23 -17
- praisonai/auto.py +1 -1
- praisonai/cli.py +144 -15
- praisonai/deploy.py +1 -1
- praisonai/inbuilt_tools/__init__.py +1 -1
- praisonai/setup/setup_conda_env.sh +55 -22
- praisonai/train.py +442 -156
- praisonai/train_vision.py +306 -0
- praisonai/ui/code.py +4 -2
- praisonai/ui/sql_alchemy.py +4 -4
- praisonai/upload_vision.py +140 -0
- praisonai-2.2.16.dist-info/METADATA +103 -0
- {praisonai-2.0.53.dist-info → praisonai-2.2.16.dist-info}/RECORD +16 -26
- {praisonai-2.0.53.dist-info → praisonai-2.2.16.dist-info}/WHEEL +1 -1
- praisonai/ui/config/.chainlit/config.toml +0 -120
- praisonai/ui/config/.chainlit/translations/bn.json +0 -231
- praisonai/ui/config/.chainlit/translations/en-US.json +0 -229
- praisonai/ui/config/.chainlit/translations/gu.json +0 -231
- praisonai/ui/config/.chainlit/translations/he-IL.json +0 -231
- praisonai/ui/config/.chainlit/translations/hi.json +0 -231
- praisonai/ui/config/.chainlit/translations/kn.json +0 -231
- praisonai/ui/config/.chainlit/translations/ml.json +0 -231
- praisonai/ui/config/.chainlit/translations/mr.json +0 -231
- praisonai/ui/config/.chainlit/translations/ta.json +0 -231
- praisonai/ui/config/.chainlit/translations/te.json +0 -231
- praisonai/ui/config/.chainlit/translations/zh-CN.json +0 -229
- praisonai-2.0.53.dist-info/LICENSE +0 -20
- praisonai-2.0.53.dist-info/METADATA +0 -673
- {praisonai-2.0.53.dist-info → praisonai-2.2.16.dist-info}/entry_points.txt +0 -0
praisonai/README.md
ADDED
praisonai/agents_generator.py
CHANGED
|
@@ -437,20 +437,26 @@ class AgentsGenerator:
|
|
|
437
437
|
llm_model = details.get('llm')
|
|
438
438
|
if llm_model:
|
|
439
439
|
llm = PraisonAIModel(
|
|
440
|
-
model=llm_model.get("model"
|
|
440
|
+
model=llm_model.get("model") or os.environ.get("MODEL_NAME") or "openai/gpt-4o",
|
|
441
|
+
base_url=self.config_list[0].get('base_url') if self.config_list else None
|
|
441
442
|
).get_model()
|
|
442
443
|
else:
|
|
443
|
-
llm = PraisonAIModel(
|
|
444
|
+
llm = PraisonAIModel(
|
|
445
|
+
base_url=self.config_list[0].get('base_url') if self.config_list else None
|
|
446
|
+
).get_model()
|
|
444
447
|
|
|
445
448
|
# Configure function calling LLM
|
|
446
449
|
function_calling_llm_model = details.get('function_calling_llm')
|
|
447
450
|
if function_calling_llm_model:
|
|
448
451
|
function_calling_llm = PraisonAIModel(
|
|
449
|
-
model=function_calling_llm_model.get("model"
|
|
452
|
+
model=function_calling_llm_model.get("model") or os.environ.get("MODEL_NAME") or "openai/gpt-4o",
|
|
453
|
+
base_url=self.config_list[0].get('base_url') if self.config_list else None
|
|
450
454
|
).get_model()
|
|
451
455
|
else:
|
|
452
|
-
function_calling_llm = PraisonAIModel(
|
|
453
|
-
|
|
456
|
+
function_calling_llm = PraisonAIModel(
|
|
457
|
+
base_url=self.config_list[0].get('base_url') if self.config_list else None
|
|
458
|
+
).get_model()
|
|
459
|
+
|
|
454
460
|
# Create CrewAI agent
|
|
455
461
|
agent = Agent(
|
|
456
462
|
role=role_filled,
|
|
@@ -460,14 +466,14 @@ class AgentsGenerator:
|
|
|
460
466
|
allow_delegation=details.get('allow_delegation', False),
|
|
461
467
|
llm=llm,
|
|
462
468
|
function_calling_llm=function_calling_llm,
|
|
463
|
-
max_iter=details.get('max_iter'
|
|
464
|
-
max_rpm=details.get('max_rpm'),
|
|
465
|
-
max_execution_time=details.get('max_execution_time'),
|
|
469
|
+
max_iter=details.get('max_iter') or 15,
|
|
470
|
+
max_rpm=details.get('max_rpm') or None,
|
|
471
|
+
max_execution_time=details.get('max_execution_time') or None,
|
|
466
472
|
verbose=details.get('verbose', True),
|
|
467
473
|
cache=details.get('cache', True),
|
|
468
|
-
system_template=details.get('system_template'),
|
|
469
|
-
prompt_template=details.get('prompt_template'),
|
|
470
|
-
response_template=details.get('response_template'),
|
|
474
|
+
system_template=details.get('system_template') or None,
|
|
475
|
+
prompt_template=details.get('prompt_template') or None,
|
|
476
|
+
response_template=details.get('response_template') or None,
|
|
471
477
|
)
|
|
472
478
|
|
|
473
479
|
# Set agent callback if provided
|
|
@@ -516,7 +522,7 @@ class AgentsGenerator:
|
|
|
516
522
|
crew = Crew(
|
|
517
523
|
agents=list(agents.values()),
|
|
518
524
|
tasks=tasks,
|
|
519
|
-
verbose=
|
|
525
|
+
verbose=True
|
|
520
526
|
)
|
|
521
527
|
|
|
522
528
|
self.logger.debug("Final Crew Configuration:")
|
|
@@ -557,8 +563,8 @@ class AgentsGenerator:
|
|
|
557
563
|
backstory=backstory_filled,
|
|
558
564
|
tools=tools_list, # Pass the entire tools list to the agent
|
|
559
565
|
allow_delegation=details.get('allow_delegation', False),
|
|
560
|
-
llm=details.get('llm', {}).get("model"
|
|
561
|
-
function_calling_llm=details.get('function_calling_llm', {}).get("model"
|
|
566
|
+
llm=details.get('llm', {}).get("model") or os.environ.get("MODEL_NAME") or "openai/gpt-4o",
|
|
567
|
+
function_calling_llm=details.get('function_calling_llm', {}).get("model") or os.environ.get("MODEL_NAME") or "openai/gpt-4o",
|
|
562
568
|
max_iter=details.get('max_iter', 15),
|
|
563
569
|
max_rpm=details.get('max_rpm'),
|
|
564
570
|
max_execution_time=details.get('max_execution_time'),
|
|
@@ -567,7 +573,7 @@ class AgentsGenerator:
|
|
|
567
573
|
system_template=details.get('system_template'),
|
|
568
574
|
prompt_template=details.get('prompt_template'),
|
|
569
575
|
response_template=details.get('response_template'),
|
|
570
|
-
reflect_llm=details.get('reflect_llm', {}).get("model"
|
|
576
|
+
reflect_llm=details.get('reflect_llm', {}).get("model") or os.environ.get("MODEL_NAME") or "openai/gpt-4o",
|
|
571
577
|
min_reflect=details.get('min_reflect', 1),
|
|
572
578
|
max_reflect=details.get('max_reflect', 3),
|
|
573
579
|
)
|
|
@@ -623,14 +629,14 @@ class AgentsGenerator:
|
|
|
623
629
|
tasks=tasks,
|
|
624
630
|
verbose=True,
|
|
625
631
|
process="hierarchical",
|
|
626
|
-
manager_llm=config.get('manager_llm'
|
|
632
|
+
manager_llm=config.get('manager_llm') or os.environ.get("MODEL_NAME") or "openai/gpt-4o",
|
|
627
633
|
memory=memory
|
|
628
634
|
)
|
|
629
635
|
else:
|
|
630
636
|
agents = PraisonAIAgents(
|
|
631
637
|
agents=list(agents.values()),
|
|
632
638
|
tasks=tasks,
|
|
633
|
-
verbose=
|
|
639
|
+
verbose=True,
|
|
634
640
|
memory=memory
|
|
635
641
|
)
|
|
636
642
|
|
praisonai/auto.py
CHANGED
|
@@ -104,7 +104,7 @@ Tools are not available for {framework}. To use tools, install:
|
|
|
104
104
|
self.client = instructor.patch(
|
|
105
105
|
OpenAI(
|
|
106
106
|
base_url=self.config_list[0]['base_url'],
|
|
107
|
-
api_key=
|
|
107
|
+
api_key=self.config_list[0]['api_key'],
|
|
108
108
|
),
|
|
109
109
|
mode=instructor.Mode.JSON,
|
|
110
110
|
)
|
praisonai/cli.py
CHANGED
|
@@ -25,7 +25,6 @@ CALL_MODULE_AVAILABLE = False
|
|
|
25
25
|
CREWAI_AVAILABLE = False
|
|
26
26
|
AUTOGEN_AVAILABLE = False
|
|
27
27
|
PRAISONAI_AVAILABLE = False
|
|
28
|
-
|
|
29
28
|
try:
|
|
30
29
|
# Create necessary directories and set CHAINLIT_APP_ROOT
|
|
31
30
|
if "CHAINLIT_APP_ROOT" not in os.environ:
|
|
@@ -114,11 +113,14 @@ class PraisonAI:
|
|
|
114
113
|
Initialize the PraisonAI object with default parameters.
|
|
115
114
|
"""
|
|
116
115
|
self.agent_yaml = agent_yaml
|
|
116
|
+
# Create config_list with AutoGen compatibility
|
|
117
|
+
api_key = os.environ.get("OPENAI_API_KEY")
|
|
117
118
|
self.config_list = [
|
|
118
119
|
{
|
|
119
120
|
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
|
|
120
121
|
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
|
|
121
|
-
'api_key':
|
|
122
|
+
'api_key': api_key,
|
|
123
|
+
'api_type': 'openai' # AutoGen expects this field
|
|
122
124
|
}
|
|
123
125
|
]
|
|
124
126
|
self.agent_file = agent_file
|
|
@@ -131,7 +133,7 @@ class PraisonAI:
|
|
|
131
133
|
"""
|
|
132
134
|
Run the PraisonAI application.
|
|
133
135
|
"""
|
|
134
|
-
self.main()
|
|
136
|
+
return self.main()
|
|
135
137
|
|
|
136
138
|
def main(self):
|
|
137
139
|
"""
|
|
@@ -139,17 +141,33 @@ class PraisonAI:
|
|
|
139
141
|
initializes the necessary attributes, and then calls the appropriate methods based on the
|
|
140
142
|
provided arguments.
|
|
141
143
|
"""
|
|
144
|
+
# Store the original agent_file from constructor
|
|
145
|
+
original_agent_file = self.agent_file
|
|
146
|
+
|
|
142
147
|
args = self.parse_args()
|
|
148
|
+
# Store args for use in handle_direct_prompt
|
|
149
|
+
self.args = args
|
|
143
150
|
invocation_cmd = "praisonai"
|
|
144
151
|
version_string = f"PraisonAI version {__version__}"
|
|
145
152
|
|
|
146
153
|
self.framework = args.framework or self.framework
|
|
147
154
|
|
|
148
155
|
if args.command:
|
|
149
|
-
if args.command.startswith("tests.test"): # Argument used for testing purposes
|
|
156
|
+
if args.command.startswith("tests.test") or args.command.startswith("tests/test"): # Argument used for testing purposes
|
|
150
157
|
print("test")
|
|
158
|
+
return "test"
|
|
151
159
|
else:
|
|
152
160
|
self.agent_file = args.command
|
|
161
|
+
elif hasattr(args, 'direct_prompt') and args.direct_prompt:
|
|
162
|
+
# Only handle direct prompt if agent_file wasn't explicitly set in constructor
|
|
163
|
+
if original_agent_file == "agents.yaml": # Default value, so safe to use direct prompt
|
|
164
|
+
result = self.handle_direct_prompt(args.direct_prompt)
|
|
165
|
+
print(result)
|
|
166
|
+
return result
|
|
167
|
+
else:
|
|
168
|
+
# Agent file was explicitly set, ignore direct prompt and use the file
|
|
169
|
+
pass
|
|
170
|
+
# If no command or direct_prompt, preserve agent_file from constructor (don't overwrite)
|
|
153
171
|
|
|
154
172
|
if args.deploy:
|
|
155
173
|
from .deploy import CloudDeployer
|
|
@@ -180,8 +198,18 @@ class PraisonAI:
|
|
|
180
198
|
package_root = os.path.dirname(os.path.abspath(__file__))
|
|
181
199
|
config_yaml_destination = os.path.join(os.getcwd(), 'config.yaml')
|
|
182
200
|
|
|
183
|
-
|
|
184
|
-
|
|
201
|
+
if not os.path.exists(config_yaml_destination):
|
|
202
|
+
config = generate_config(
|
|
203
|
+
model_name=args.model,
|
|
204
|
+
hf_model_name=args.hf,
|
|
205
|
+
ollama_model_name=args.ollama,
|
|
206
|
+
dataset=[{
|
|
207
|
+
"name": args.dataset
|
|
208
|
+
}]
|
|
209
|
+
)
|
|
210
|
+
with open('config.yaml', 'w') as f:
|
|
211
|
+
yaml.dump(config, f, default_flow_style=False, indent=2)
|
|
212
|
+
elif args.model or args.hf or args.ollama or (args.dataset and args.dataset != "yahma/alpaca-cleaned"):
|
|
185
213
|
config = generate_config(
|
|
186
214
|
model_name=args.model,
|
|
187
215
|
hf_model_name=args.hf,
|
|
@@ -192,6 +220,9 @@ class PraisonAI:
|
|
|
192
220
|
)
|
|
193
221
|
with open('config.yaml', 'w') as f:
|
|
194
222
|
yaml.dump(config, f, default_flow_style=False, indent=2)
|
|
223
|
+
else:
|
|
224
|
+
with open(config_yaml_destination, 'r') as f:
|
|
225
|
+
config = yaml.safe_load(f)
|
|
195
226
|
|
|
196
227
|
# Overwrite huggingface_save and ollama_save if --hf or --ollama are provided
|
|
197
228
|
if args.hf:
|
|
@@ -218,7 +249,18 @@ class PraisonAI:
|
|
|
218
249
|
print("All packages installed.")
|
|
219
250
|
|
|
220
251
|
train_args = sys.argv[2:] # Get all arguments after 'train'
|
|
221
|
-
|
|
252
|
+
|
|
253
|
+
# Check if this is a vision model - handle all case variations
|
|
254
|
+
model_name = config.get("model_name", "").lower()
|
|
255
|
+
is_vision_model = any(x in model_name for x in ["-vl-", "-vl", "vl-", "-vision-", "-vision", "vision-", "visionmodel"])
|
|
256
|
+
|
|
257
|
+
# Choose appropriate training script
|
|
258
|
+
if is_vision_model:
|
|
259
|
+
train_script_path = os.path.join(package_root, 'train_vision.py')
|
|
260
|
+
print("Using vision training script for VL model...")
|
|
261
|
+
else:
|
|
262
|
+
train_script_path = os.path.join(package_root, 'train.py')
|
|
263
|
+
print("Using standard training script...")
|
|
222
264
|
|
|
223
265
|
# Set environment variables
|
|
224
266
|
env = os.environ.copy()
|
|
@@ -285,22 +327,41 @@ class PraisonAI:
|
|
|
285
327
|
"""
|
|
286
328
|
Parse the command-line arguments for the PraisonAI CLI.
|
|
287
329
|
"""
|
|
330
|
+
# Check if we're running in a test environment
|
|
331
|
+
in_test_env = (
|
|
332
|
+
'pytest' in sys.argv[0] or
|
|
333
|
+
'unittest' in sys.argv[0] or
|
|
334
|
+
any('test' in arg for arg in sys.argv[1:3]) or # Check first few args for test indicators
|
|
335
|
+
'pytest' in sys.modules or
|
|
336
|
+
'unittest' in sys.modules
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
# Define special commands
|
|
340
|
+
special_commands = ['chat', 'code', 'call', 'realtime', 'train', 'ui']
|
|
341
|
+
|
|
288
342
|
parser = argparse.ArgumentParser(prog="praisonai", description="praisonAI command-line interface")
|
|
289
343
|
parser.add_argument("--framework", choices=["crewai", "autogen", "praisonai"], help="Specify the framework")
|
|
290
344
|
parser.add_argument("--ui", choices=["chainlit", "gradio"], help="Specify the UI framework (gradio or chainlit).")
|
|
291
345
|
parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
|
292
346
|
parser.add_argument("--init", nargs=argparse.REMAINDER, help="Initialize agents with optional topic")
|
|
293
|
-
parser.add_argument("command", nargs="?", help="Command to run")
|
|
347
|
+
parser.add_argument("command", nargs="?", help="Command to run or direct prompt")
|
|
294
348
|
parser.add_argument("--deploy", action="store_true", help="Deploy the application")
|
|
295
349
|
parser.add_argument("--model", type=str, help="Model name")
|
|
350
|
+
parser.add_argument("--llm", type=str, help="LLM model to use for direct prompts")
|
|
296
351
|
parser.add_argument("--hf", type=str, help="Hugging Face model name")
|
|
297
352
|
parser.add_argument("--ollama", type=str, help="Ollama model name")
|
|
298
353
|
parser.add_argument("--dataset", type=str, help="Dataset name for training", default="yahma/alpaca-cleaned")
|
|
299
354
|
parser.add_argument("--realtime", action="store_true", help="Start the realtime voice interaction interface")
|
|
300
355
|
parser.add_argument("--call", action="store_true", help="Start the PraisonAI Call server")
|
|
301
356
|
parser.add_argument("--public", action="store_true", help="Use ngrok to expose the server publicly (only with --call)")
|
|
302
|
-
|
|
357
|
+
|
|
358
|
+
# If we're in a test environment, parse with empty args to avoid pytest interference
|
|
359
|
+
if in_test_env:
|
|
360
|
+
args, unknown_args = parser.parse_known_args([])
|
|
361
|
+
else:
|
|
362
|
+
args, unknown_args = parser.parse_known_args()
|
|
303
363
|
|
|
364
|
+
# Handle special cases first
|
|
304
365
|
if unknown_args and unknown_args[0] == '-b' and unknown_args[1] == 'api:app':
|
|
305
366
|
args.command = 'agents.yaml'
|
|
306
367
|
if args.command == 'api:app' or args.command == '/app/api:app':
|
|
@@ -331,9 +392,7 @@ class PraisonAI:
|
|
|
331
392
|
call_module.main(call_args)
|
|
332
393
|
sys.exit(0)
|
|
333
394
|
|
|
334
|
-
# Handle special commands
|
|
335
|
-
special_commands = ['chat', 'code', 'call', 'realtime', 'train', 'ui']
|
|
336
|
-
|
|
395
|
+
# Handle special commands
|
|
337
396
|
if args.command in special_commands:
|
|
338
397
|
if args.command == 'chat':
|
|
339
398
|
if not CHAINLIT_AVAILABLE:
|
|
@@ -380,9 +439,8 @@ class PraisonAI:
|
|
|
380
439
|
sys.exit(0)
|
|
381
440
|
|
|
382
441
|
elif args.command == 'train':
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
sys.exit(1)
|
|
442
|
+
package_root = os.path.dirname(os.path.abspath(__file__))
|
|
443
|
+
config_yaml_destination = os.path.join(os.getcwd(), 'config.yaml')
|
|
386
444
|
|
|
387
445
|
elif args.command == 'ui':
|
|
388
446
|
if not CHAINLIT_AVAILABLE:
|
|
@@ -402,8 +460,79 @@ class PraisonAI:
|
|
|
402
460
|
print("pip install praisonaiagents # For PraisonAIAgents\n")
|
|
403
461
|
sys.exit(1)
|
|
404
462
|
|
|
463
|
+
# Handle direct prompt if command is not a special command or file
|
|
464
|
+
# Skip this during testing to avoid pytest arguments interfering
|
|
465
|
+
if not in_test_env and args.command and not args.command.endswith('.yaml') and args.command not in special_commands:
|
|
466
|
+
args.direct_prompt = args.command
|
|
467
|
+
args.command = None
|
|
468
|
+
|
|
405
469
|
return args
|
|
406
470
|
|
|
471
|
+
def handle_direct_prompt(self, prompt):
|
|
472
|
+
"""
|
|
473
|
+
Handle direct prompt by creating a single agent and running it.
|
|
474
|
+
"""
|
|
475
|
+
if PRAISONAI_AVAILABLE:
|
|
476
|
+
agent_config = {
|
|
477
|
+
"name": "DirectAgent",
|
|
478
|
+
"role": "Assistant",
|
|
479
|
+
"goal": "Complete the given task",
|
|
480
|
+
"backstory": "You are a helpful AI assistant"
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
# Add llm if specified
|
|
484
|
+
if hasattr(self, 'args') and self.args.llm:
|
|
485
|
+
agent_config["llm"] = self.args.llm
|
|
486
|
+
|
|
487
|
+
agent = PraisonAgent(**agent_config)
|
|
488
|
+
result = agent.start(prompt)
|
|
489
|
+
return result
|
|
490
|
+
elif CREWAI_AVAILABLE:
|
|
491
|
+
agent_config = {
|
|
492
|
+
"name": "DirectAgent",
|
|
493
|
+
"role": "Assistant",
|
|
494
|
+
"goal": "Complete the given task",
|
|
495
|
+
"backstory": "You are a helpful AI assistant"
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
# Add llm if specified
|
|
499
|
+
if hasattr(self, 'args') and self.args.llm:
|
|
500
|
+
agent_config["llm"] = self.args.llm
|
|
501
|
+
|
|
502
|
+
agent = Agent(**agent_config)
|
|
503
|
+
task = Task(
|
|
504
|
+
description=prompt,
|
|
505
|
+
agent=agent
|
|
506
|
+
)
|
|
507
|
+
crew = Crew(
|
|
508
|
+
agents=[agent],
|
|
509
|
+
tasks=[task]
|
|
510
|
+
)
|
|
511
|
+
return crew.kickoff()
|
|
512
|
+
elif AUTOGEN_AVAILABLE:
|
|
513
|
+
config_list = self.config_list
|
|
514
|
+
# Add llm if specified
|
|
515
|
+
if hasattr(self, 'args') and self.args.llm:
|
|
516
|
+
config_list[0]['model'] = self.args.llm
|
|
517
|
+
|
|
518
|
+
assistant = autogen.AssistantAgent(
|
|
519
|
+
name="DirectAgent",
|
|
520
|
+
llm_config={"config_list": config_list}
|
|
521
|
+
)
|
|
522
|
+
user_proxy = autogen.UserProxyAgent(
|
|
523
|
+
name="UserProxy",
|
|
524
|
+
code_execution_config={"work_dir": "coding"}
|
|
525
|
+
)
|
|
526
|
+
user_proxy.initiate_chat(assistant, message=prompt)
|
|
527
|
+
return "Task completed"
|
|
528
|
+
else:
|
|
529
|
+
print("[red]ERROR: No framework is installed. Please install at least one framework:[/red]")
|
|
530
|
+
print("\npip install \"praisonai\\[crewai]\" # For CrewAI")
|
|
531
|
+
print("pip install \"praisonai\\[autogen]\" # For AutoGen")
|
|
532
|
+
print("pip install \"praisonai\\[crewai,autogen]\" # For both frameworks\n")
|
|
533
|
+
print("pip install praisonaiagents # For PraisonAIAgents\n")
|
|
534
|
+
sys.exit(1)
|
|
535
|
+
|
|
407
536
|
def create_chainlit_chat_interface(self):
|
|
408
537
|
"""
|
|
409
538
|
Create a Chainlit interface for the chat application.
|
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==2.
|
|
59
|
+
file.write("RUN pip install flask praisonai==2.2.16 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
|
|
|
@@ -11,6 +11,38 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
11
11
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
12
12
|
# Linux
|
|
13
13
|
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
|
|
14
|
+
|
|
15
|
+
# Install libcurl development package if not present (Debian based)
|
|
16
|
+
if command -v dpkg &> /dev/null; then
|
|
17
|
+
if ! dpkg -s libcurl4-openssl-dev &> /dev/null; then
|
|
18
|
+
echo "libcurl4-openssl-dev is not installed. Installing..."
|
|
19
|
+
sudo apt-get update
|
|
20
|
+
sudo apt-get install -y libcurl4-openssl-dev
|
|
21
|
+
else
|
|
22
|
+
echo "libcurl4-openssl-dev is already installed."
|
|
23
|
+
fi
|
|
24
|
+
else
|
|
25
|
+
echo "Non-Debian based Linux detected. Please ensure libcurl development libraries are installed."
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Check if ollama is installed and executable; if not, install it
|
|
29
|
+
if ! command -v ollama &> /dev/null; then
|
|
30
|
+
echo "Ollama is not installed. Installing Ollama..."
|
|
31
|
+
curl -fsSL https://ollama.com/install.sh | sh
|
|
32
|
+
|
|
33
|
+
# Generate SSH key non-interactively only if it doesn't already exist
|
|
34
|
+
if [ ! -f ~/.ssh/id_ed25519 ]; then
|
|
35
|
+
echo "Generating SSH key for Ollama..."
|
|
36
|
+
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519 -q
|
|
37
|
+
else
|
|
38
|
+
echo "SSH key ~/.ssh/id_ed25519 already exists. Skipping generation."
|
|
39
|
+
fi
|
|
40
|
+
echo "Copying SSH key to /usr/share/ollama/.ollama..."
|
|
41
|
+
sudo cp ~/.ssh/id_ed25519 /usr/share/ollama/.ollama
|
|
42
|
+
else
|
|
43
|
+
echo "Ollama is already installed."
|
|
44
|
+
fi
|
|
45
|
+
|
|
14
46
|
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
|
15
47
|
# Windows
|
|
16
48
|
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
|
|
@@ -21,12 +53,12 @@ else
|
|
|
21
53
|
exit 1
|
|
22
54
|
fi
|
|
23
55
|
|
|
24
|
-
# Check if conda is
|
|
56
|
+
# Check if conda is installed
|
|
25
57
|
if ! command -v conda &> /dev/null; then
|
|
26
58
|
echo "Conda is not installed. Installing Miniconda..."
|
|
27
|
-
wget $MINICONDA_URL -O ~/miniconda.sh
|
|
28
|
-
bash ~/miniconda.sh -b -p $HOME/miniconda
|
|
29
|
-
source $HOME/miniconda/bin/activate
|
|
59
|
+
wget "$MINICONDA_URL" -O ~/miniconda.sh
|
|
60
|
+
bash ~/miniconda.sh -b -p "$HOME/miniconda"
|
|
61
|
+
source "$HOME/miniconda/bin/activate"
|
|
30
62
|
conda init
|
|
31
63
|
else
|
|
32
64
|
echo "Conda is already installed."
|
|
@@ -34,39 +66,40 @@ fi
|
|
|
34
66
|
|
|
35
67
|
# Create and activate the Conda environment
|
|
36
68
|
ENV_NAME="praison_env"
|
|
37
|
-
if conda info --envs | grep -q $ENV_NAME; then
|
|
69
|
+
if conda info --envs | grep -q "$ENV_NAME"; then
|
|
38
70
|
echo "Environment $ENV_NAME already exists. Recreating..."
|
|
39
|
-
conda env remove -y -n $ENV_NAME
|
|
71
|
+
conda env remove -y -n "$ENV_NAME"
|
|
40
72
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
41
|
-
|
|
42
|
-
conda create --name $ENV_NAME python=3.10 pytorch=2.3.0 -c pytorch -y
|
|
73
|
+
conda create --name "$ENV_NAME" python=3.10 pytorch=2.3.0 -c pytorch -y
|
|
43
74
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
44
|
-
|
|
45
|
-
conda create --name $ENV_NAME python=3.10 pytorch=2.3.0 cudatoolkit=11.8 -c pytorch -c nvidia -y
|
|
75
|
+
conda create --name "$ENV_NAME" python=3.10 pytorch=2.3.0 cudatoolkit=11.8 -c pytorch -c nvidia -y
|
|
46
76
|
fi
|
|
47
|
-
# conda activate $ENV_NAME
|
|
48
77
|
else
|
|
49
78
|
echo "Creating new environment $ENV_NAME..."
|
|
50
79
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
51
|
-
|
|
52
|
-
conda create --name $ENV_NAME python=3.10 pytorch=2.3.0 -c pytorch -y
|
|
80
|
+
conda create --name "$ENV_NAME" python=3.10 pytorch=2.3.0 -c pytorch -y
|
|
53
81
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
54
|
-
|
|
55
|
-
conda create --name $ENV_NAME python=3.10 pytorch=2.3.0 cudatoolkit=11.8 -c pytorch -c nvidia -y
|
|
82
|
+
conda create --name "$ENV_NAME" python=3.10 pytorch=2.3.0 cudatoolkit=11.8 -c pytorch -c nvidia -y
|
|
56
83
|
fi
|
|
57
|
-
# conda activate $ENV_NAME
|
|
58
84
|
fi
|
|
59
85
|
|
|
60
|
-
#
|
|
86
|
+
# Activate the environment
|
|
87
|
+
source "$HOME/miniconda/bin/activate" "$ENV_NAME"
|
|
88
|
+
|
|
89
|
+
# Install cmake via conda
|
|
90
|
+
echo "Installing cmake..."
|
|
91
|
+
conda install -y cmake
|
|
61
92
|
|
|
62
|
-
# Get full path of pip
|
|
63
|
-
PIP_FULL_PATH=$(conda run -n $ENV_NAME which pip)
|
|
93
|
+
# Get full path of pip within the activated environment
|
|
94
|
+
PIP_FULL_PATH=$(conda run -n "$ENV_NAME" which pip)
|
|
64
95
|
|
|
65
|
-
# Install other packages
|
|
66
|
-
# Use PIP_FULL_PATH to run pip commands
|
|
96
|
+
# Install other packages using pip
|
|
67
97
|
$PIP_FULL_PATH install --upgrade pip
|
|
68
98
|
$PIP_FULL_PATH install "xformers==0.0.26.post1"
|
|
69
|
-
$PIP_FULL_PATH install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@
|
|
99
|
+
$PIP_FULL_PATH install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@53a773e4fbc53a1d96c7ba107e5fe75dab07027b"
|
|
70
100
|
$PIP_FULL_PATH install --no-deps "trl<0.9.0" peft accelerate bitsandbytes
|
|
101
|
+
$PIP_FULL_PATH install unsloth_zoo
|
|
102
|
+
$PIP_FULL_PATH install cut_cross_entropy
|
|
103
|
+
$PIP_FULL_PATH install sentencepiece protobuf datasets huggingface_hub hf_transfer wandb
|
|
71
104
|
|
|
72
105
|
echo "Setup completed successfully!"
|