PraisonAI 2.2.18__cp313-cp313-manylinux_2_39_x86_64.whl → 2.2.20__cp313-cp313-manylinux_2_39_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/__init__.py CHANGED
@@ -3,4 +3,4 @@ import os
3
3
  os.environ["OTEL_SDK_DISABLED"] = "true"
4
4
  os.environ["EC_TELEMETRY"] = "false"
5
5
  from .cli import PraisonAI
6
- from .version import __version__
6
+ from .version import __version__
praisonai/api/call.py CHANGED
@@ -39,9 +39,6 @@ LOG_EVENT_TYPES = [
39
39
 
40
40
  app = FastAPI()
41
41
 
42
- if not OPENAI_API_KEY:
43
- raise ValueError('Missing the OpenAI API key. Please set it in the .env file.')
44
-
45
42
  # Set up logging
46
43
  logger = logging.getLogger(__name__)
47
44
  log_level = os.getenv("LOGLEVEL", "INFO").upper()
@@ -266,6 +263,9 @@ def setup_public_url(port):
266
263
 
267
264
  def run_server(port: int, use_public: bool = False):
268
265
  """Run the FastAPI server using uvicorn."""
266
+ if not OPENAI_API_KEY:
267
+ raise ValueError('Missing the OpenAI API key. Please set it in the .env file or configure it through the GUI.')
268
+
269
269
  if use_public:
270
270
  setup_public_url(port)
271
271
  else:
praisonai/cli.py CHANGED
@@ -54,7 +54,7 @@ except ImportError:
54
54
  pass
55
55
 
56
56
  try:
57
- from crewai import Agent, Task, Crew
57
+ import crewai
58
58
  CREWAI_AVAILABLE = True
59
59
  except ImportError:
60
60
  pass
@@ -147,6 +147,21 @@ class PraisonAI:
147
147
  """
148
148
  return self.main()
149
149
 
150
+ def read_stdin_if_available(self):
151
+ """
152
+ Read from stdin if it's available (when data is piped in).
153
+ Returns the stdin content or None if no piped input is available.
154
+ """
155
+ try:
156
+ # Check if stdin is not a terminal (i.e., has piped input)
157
+ if not sys.stdin.isatty():
158
+ stdin_content = sys.stdin.read().strip()
159
+ return stdin_content if stdin_content else None
160
+ except Exception:
161
+ # If there's any error reading stdin, ignore it
162
+ pass
163
+ return None
164
+
150
165
  def main(self):
151
166
  """
152
167
  The main function of the PraisonAI object. It parses the command-line arguments,
@@ -164,21 +179,41 @@ class PraisonAI:
164
179
 
165
180
  self.framework = args.framework or self.framework
166
181
 
182
+ # Check for piped input from stdin
183
+ stdin_input = self.read_stdin_if_available()
184
+
167
185
  if args.command:
168
186
  if args.command.startswith("tests.test") or args.command.startswith("tests/test"): # Argument used for testing purposes
169
187
  print("test")
170
188
  return "test"
171
189
  else:
172
- self.agent_file = args.command
190
+ # If stdin input is available, append it to the command
191
+ if stdin_input:
192
+ combined_prompt = f"{args.command} {stdin_input}"
193
+ result = self.handle_direct_prompt(combined_prompt)
194
+ print(result)
195
+ return result
196
+ else:
197
+ self.agent_file = args.command
173
198
  elif hasattr(args, 'direct_prompt') and args.direct_prompt:
174
199
  # Only handle direct prompt if agent_file wasn't explicitly set in constructor
175
200
  if original_agent_file == "agents.yaml": # Default value, so safe to use direct prompt
176
- result = self.handle_direct_prompt(args.direct_prompt)
201
+ # If stdin input is available, append it to the direct prompt
202
+ prompt = args.direct_prompt
203
+ if stdin_input:
204
+ prompt = f"{args.direct_prompt} {stdin_input}"
205
+ result = self.handle_direct_prompt(prompt)
177
206
  print(result)
178
207
  return result
179
208
  else:
180
209
  # Agent file was explicitly set, ignore direct prompt and use the file
181
210
  pass
211
+ elif stdin_input:
212
+ # If only stdin input is provided (no command), use it as direct prompt
213
+ if original_agent_file == "agents.yaml": # Default value, so safe to use stdin as prompt
214
+ result = self.handle_direct_prompt(stdin_input)
215
+ print(result)
216
+ return result
182
217
  # If no command or direct_prompt, preserve agent_file from constructor (don't overwrite)
183
218
 
184
219
  if args.deploy:
@@ -248,17 +283,29 @@ class PraisonAI:
248
283
  print("All packages installed")
249
284
  return
250
285
 
286
+ # Check if conda is available and environment exists
287
+ conda_available = True
288
+ conda_env_exists = False
289
+
251
290
  try:
252
291
  result = subprocess.check_output(['conda', 'env', 'list'])
253
292
  if 'praison_env' in result.decode('utf-8'):
254
293
  print("Conda environment 'praison_env' found.")
294
+ conda_env_exists = True
255
295
  else:
256
- raise subprocess.CalledProcessError(1, 'grep')
257
- except subprocess.CalledProcessError:
258
- print("Conda environment 'praison_env' not found. Setting it up...")
259
- from praisonai.setup.setup_conda_env import main as setup_conda_main
260
- setup_conda_main()
261
- print("All packages installed.")
296
+ print("Conda environment 'praison_env' not found. Setting it up...")
297
+ from praisonai.setup.setup_conda_env import main as setup_conda_main
298
+ setup_conda_main()
299
+ print("All packages installed.")
300
+ # Check again if environment was created successfully
301
+ try:
302
+ result = subprocess.check_output(['conda', 'env', 'list'])
303
+ conda_env_exists = 'praison_env' in result.decode('utf-8')
304
+ except subprocess.CalledProcessError:
305
+ conda_env_exists = False
306
+ except (subprocess.CalledProcessError, FileNotFoundError):
307
+ print("Conda not available or failed to check environment.")
308
+ conda_available = False
262
309
 
263
310
  train_args = sys.argv[2:] # Get all arguments after 'train'
264
311
 
@@ -278,7 +325,18 @@ class PraisonAI:
278
325
  env = os.environ.copy()
279
326
  env['PYTHONUNBUFFERED'] = '1'
280
327
 
281
- stream_subprocess(['conda', 'run', '--no-capture-output', '--name', 'praison_env', 'python', '-u', train_script_path, 'train'], env=env)
328
+ # Try conda run first, fallback to direct Python execution
329
+ if conda_available and conda_env_exists:
330
+ try:
331
+ print("Attempting to run training using conda environment...")
332
+ stream_subprocess(['conda', 'run', '--no-capture-output', '--name', 'praison_env', 'python', '-u', train_script_path, 'train'], env=env)
333
+ except subprocess.CalledProcessError as e:
334
+ print(f"Conda run failed with error: {e}")
335
+ print("Falling back to direct Python execution...")
336
+ stream_subprocess([sys.executable, '-u', train_script_path, 'train'], env=env)
337
+ else:
338
+ print("Conda environment not available, using direct Python execution...")
339
+ stream_subprocess([sys.executable, '-u', train_script_path, 'train'], env=env)
282
340
  return
283
341
 
284
342
  if args.auto or self.auto:
@@ -500,6 +558,7 @@ class PraisonAI:
500
558
  result = agent.start(prompt)
501
559
  return result
502
560
  elif CREWAI_AVAILABLE:
561
+ from crewai import Agent, Task, Crew
503
562
  agent_config = {
504
563
  "name": "DirectAgent",
505
564
  "role": "Assistant",
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.2.18 gunicorn markdown\n")
59
+ file.write("RUN pip install flask praisonai==2.2.20 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
 
praisonai/inc/models.py CHANGED
@@ -1,9 +1,13 @@
1
1
  # praisonai/inc/models.py
2
2
  import os
3
3
  import logging
4
+ from urllib.parse import urlparse
4
5
  logger = logging.getLogger(__name__)
5
6
  logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper(), format='%(asctime)s - %(levelname)s - %(message)s')
6
7
 
8
+ # Constants
9
+ LOCAL_SERVER_API_KEY_PLACEHOLDER = "not-needed"
10
+
7
11
  # Conditionally import modules based on availability
8
12
  try:
9
13
  from langchain_openai import ChatOpenAI # pip install langchain-openai
@@ -71,11 +75,27 @@ class PraisonAIModel:
71
75
  self.model_name = self.model.replace("openrouter/", "")
72
76
  else:
73
77
  self.api_key_var = api_key_var or "OPENAI_API_KEY"
74
- self.base_url = base_url or os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
78
+ self.base_url = base_url or os.environ.get("OPENAI_API_BASE") or os.environ.get("OPENAI_BASE_URL") or "https://api.openai.com/v1"
75
79
  self.model_name = self.model
76
80
  logger.debug(f"Initialized PraisonAIModel with model {self.model_name}, api_key_var {self.api_key_var}, and base_url {self.base_url}")
77
- # Use explicit API key if provided, otherwise fall back to environment variable
78
- self.api_key = api_key or os.environ.get(self.api_key_var, "nokey")
81
+
82
+ # Get API key from environment
83
+ self.api_key = api_key or os.environ.get(self.api_key_var)
84
+
85
+ # For local servers, allow placeholder API key if base_url is set to non-OpenAI endpoint
86
+ if not self.api_key and self.base_url:
87
+ parsed_url = urlparse(self.base_url)
88
+ is_local = (parsed_url.hostname in ["localhost", "127.0.0.1"] or
89
+ "api.openai.com" not in self.base_url)
90
+ if is_local:
91
+ self.api_key = LOCAL_SERVER_API_KEY_PLACEHOLDER
92
+
93
+ if not self.api_key:
94
+ raise ValueError(
95
+ f"{self.api_key_var} environment variable is required for the default OpenAI service. "
96
+ f"For local servers, set {self.api_key_var}='{LOCAL_SERVER_API_KEY_PLACEHOLDER}' and OPENAI_API_BASE to your local endpoint."
97
+ )
98
+
79
99
 
80
100
  def get_model(self):
81
101
  """
@@ -127,4 +147,4 @@ class PraisonAIModel:
127
147
  raise ImportError(
128
148
  "Required Langchain Integration 'langchain-openai' not found. "
129
149
  "Please install with 'pip install langchain-openai'"
130
- )
150
+ )
@@ -0,0 +1,56 @@
1
+ """
2
+ Database configuration utilities for PraisonAI UI components.
3
+
4
+ This module provides centralized database configuration functionality,
5
+ particularly for handling the FORCE_SQLITE environment variable.
6
+ """
7
+
8
+ import os
9
+ from typing import Optional, Tuple
10
+
11
+
12
+ def should_force_sqlite() -> bool:
13
+ """
14
+ Check if FORCE_SQLITE environment variable is set to true.
15
+
16
+ Returns:
17
+ bool: True if FORCE_SQLITE is set to "true" (case-insensitive), False otherwise.
18
+ """
19
+ return os.getenv("FORCE_SQLITE", "false").lower() == "true"
20
+
21
+
22
+ def get_database_url_with_sqlite_override() -> Optional[str]:
23
+ """
24
+ Get database URL respecting FORCE_SQLITE flag.
25
+
26
+ When FORCE_SQLITE=true, this function returns None to force SQLite usage.
27
+ Otherwise, it returns the appropriate database URL from environment variables.
28
+
29
+ Returns:
30
+ Optional[str]: Database URL if external database should be used, None for SQLite.
31
+ """
32
+ if should_force_sqlite():
33
+ return None
34
+
35
+ database_url = os.getenv("DATABASE_URL")
36
+ supabase_url = os.getenv("SUPABASE_DATABASE_URL")
37
+ return supabase_url if supabase_url else database_url
38
+
39
+
40
+ def get_database_config_for_sqlalchemy() -> Tuple[Optional[str], Optional[str]]:
41
+ """
42
+ Get database configuration for SQLAlchemy module respecting FORCE_SQLITE flag.
43
+
44
+ Returns:
45
+ Tuple[Optional[str], Optional[str]]: (DATABASE_URL, SUPABASE_DATABASE_URL)
46
+ Both will be None if FORCE_SQLITE=true, otherwise original values.
47
+ """
48
+ if should_force_sqlite():
49
+ return None, None
50
+ else:
51
+ database_url = os.getenv("DATABASE_URL")
52
+ supabase_url = os.getenv("SUPABASE_DATABASE_URL")
53
+ # Apply Supabase override logic
54
+ if supabase_url:
55
+ database_url = supabase_url
56
+ return database_url, supabase_url
praisonai/ui/db.py CHANGED
@@ -9,6 +9,7 @@ from sqlalchemy.orm import sessionmaker
9
9
  from sql_alchemy import SQLAlchemyDataLayer
10
10
  import chainlit.data as cl_data
11
11
  from chainlit.types import ThreadDict
12
+ from database_config import get_database_url_with_sqlite_override
12
13
 
13
14
  def ensure_directories():
14
15
  """Ensure required directories exist"""
@@ -57,10 +58,8 @@ ensure_directories()
57
58
 
58
59
  class DatabaseManager(SQLAlchemyDataLayer):
59
60
  def __init__(self):
60
- self.database_url = os.getenv("DATABASE_URL")
61
- supabase_url = os.getenv("SUPABASE_DATABASE_URL")
62
- if supabase_url:
63
- self.database_url = supabase_url
61
+ # Check FORCE_SQLITE flag to bypass external database detection
62
+ self.database_url = get_database_url_with_sqlite_override()
64
63
 
65
64
  if self.database_url:
66
65
  self.conninfo = self.database_url
@@ -29,16 +29,14 @@ from sqlalchemy import text
29
29
  from sqlalchemy.exc import SQLAlchemyError
30
30
  from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine
31
31
  from sqlalchemy.orm import sessionmaker
32
+ from database_config import get_database_config_for_sqlalchemy
32
33
 
33
34
  if TYPE_CHECKING:
34
35
  from chainlit.element import Element
35
36
  from chainlit.step import StepDict
36
37
 
37
- DATABASE_URL = os.getenv("DATABASE_URL")
38
- SUPABASE_DATABASE_URL = os.getenv("SUPABASE_DATABASE_URL")
39
- if SUPABASE_DATABASE_URL:
40
- # If a Supabase database URL is provided, use it.
41
- DATABASE_URL = SUPABASE_DATABASE_URL
38
+ # Check FORCE_SQLITE flag to bypass external database detection
39
+ DATABASE_URL, SUPABASE_DATABASE_URL = get_database_config_for_sqlalchemy()
42
40
 
43
41
  class SQLAlchemyDataLayer(BaseDataLayer):
44
42
  def __init__(
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PraisonAI
3
- Version: 2.2.18
3
+ Version: 2.2.20
4
4
  Summary: PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
5
5
  Author: Mervin Praison
6
- Requires-Python: >=3.10,<3.13
6
+ Requires-Python: >=3.10
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Programming Language :: Python :: 3.10
9
9
  Classifier: Programming Language :: Python :: 3.11
@@ -1,17 +1,17 @@
1
1
  praisonai/README.md,sha256=dXaEAByiWlJPE8_k-13lsNIEuvHdzmzJzJ8IVa84thM,195
2
- praisonai/__init__.py,sha256=JrgyPlzZfLlozoW7SHZ1nVJ63rLPR3ki2k5ZPywYrnI,175
2
+ praisonai/__init__.py,sha256=SAoNxA9ITH75eBUULjZZCu7Oia5m1gkQIS3Fl0dCpmY,176
3
3
  praisonai/__main__.py,sha256=MVgsjMThjBexHt4nhd760JCqvP4x0IQcwo8kULOK4FQ,144
4
4
  praisonai/agents_generator.py,sha256=IMD5VTYL0fUEiCUcoADGAfe2tBtPHJa-tRmN8g525bM,29353
5
- praisonai/api/call.py,sha256=krOfTCZM_bdbsNuWQ1PijzCHECkDvEi9jIvvZaDQUUU,11035
5
+ praisonai/api/call.py,sha256=-dV9DKNDi4w9vN6K63TUh15_PC0M5KzYOmBqHbuJqq0,11079
6
6
  praisonai/auto.py,sha256=n4rhiNckKv0Vtn2OnhDVVuOBxmm3CpimM9Y-ZVN9H9E,9240
7
7
  praisonai/chainlit_ui.py,sha256=VKf_--cONLIBMymMY8j-oj6Pq_rw3pHtXOqF2wZ9gYI,12220
8
- praisonai/cli.py,sha256=Tw2HT4Orgx4WW6RDB-f9ssvFPdlyJlHTc_3G7Uve060,27893
9
- praisonai/deploy.py,sha256=9_n1GdjdP8cFoaUISRwN9wiwDtAhYHkZ3W6Dxt1O87g,6028
8
+ praisonai/cli.py,sha256=nGfkK78xz4mSK6zuOiNxDyoedJ3NMB-HWVZJ1x-J0aY,30859
9
+ praisonai/deploy.py,sha256=1YzXLDWaWDZjFsN7xq9T0nhWQV-foENE_8d7T7LNrZ0,6028
10
10
  praisonai/inbuilt_tools/__init__.py,sha256=mZOEximj3zCyJHq9Lz0bGXhQpBsa_QR-R-yA9UKC3zI,565
11
11
  praisonai/inbuilt_tools/autogen_tools.py,sha256=kJdEv61BTYvdHOaURNEpBcWq8Rs-oC03loNFTIjT-ak,4687
12
12
  praisonai/inc/__init__.py,sha256=sPDlYBBwdk0VlWzaaM_lG0_LD07lS2HRGvPdxXJFiYg,62
13
13
  praisonai/inc/config.py,sha256=up2-841ruK7MCUUT3xkWBA5S6WsY0sFODNfcT6Q4Wms,3333
14
- praisonai/inc/models.py,sha256=lWzKBiGXpvv2L6SD3jJo5kTaH1Senm1HvRMCKlYkmjk,5718
14
+ praisonai/inc/models.py,sha256=hKcyzMxAFWBTnIjk_ngfZUGmb1ubkgqx8I8cJ0Kr_Xc,6556
15
15
  praisonai/public/android-chrome-192x192.png,sha256=ENJEqhDE3XEQViRhKNDezQKRiOiuHOUj5nzRN43fz50,6535
16
16
  praisonai/public/android-chrome-512x512.png,sha256=4txEwB0cJkxFVarRdvFGJZR1DtWJ2h-L_2cUEjBXHAc,15244
17
17
  praisonai/public/apple-touch-icon.png,sha256=YLlEhlenm24QY_yv-5wb_mxDxJ8H22H_S8Khlvz-zVA,6001
@@ -57,7 +57,8 @@ praisonai/ui/config/translations/ta.json,sha256=8JPW6BwLN2dl9wuq5wSkMvazcY8lM5v1
57
57
  praisonai/ui/config/translations/te.json,sha256=JzW2YXWg1qqvWgIvEgMelQz5s6EzTb_uD_3TEHAHiQw,23526
58
58
  praisonai/ui/config/translations/zh-CN.json,sha256=aLBSSSQ0yojlYGuMMlOYvkD_ruG9-d2AgnjJWhPODVw,11737
59
59
  praisonai/ui/context.py,sha256=oWO2I_WBZb7kZnuXItf18EJX0ZQv-1nAd8rxhwhuuDU,11871
60
- praisonai/ui/db.py,sha256=2ljFHRisGnu4h-vKQdKYiBVc4sWa-BORhMmOC9Xt6xk,11426
60
+ praisonai/ui/database_config.py,sha256=rW0YRUWom5yC4_5MfHP0fnMG7jHKdDYXvnUZc0JOGPA,1838
61
+ praisonai/ui/db.py,sha256=CLY_fWmy2uwIZNby2Ya7FBvh2o2tKje8fkXAmtRwky4,11450
61
62
  praisonai/ui/public/fantasy.svg,sha256=4Gs3kIOux-pjGtw6ogI_rv5_viVJxnE5gRwGilsSg0o,1553
62
63
  praisonai/ui/public/game.svg,sha256=y2QMaA01m8XzuDjTOBWzupOC3-TpnUl9ah89mIhviUw,2406
63
64
  praisonai/ui/public/logo_dark.png,sha256=frHz1zkrnivGssJgk9iy1cabojkVgm8B4MllFwL_CnI,17050
@@ -69,11 +70,11 @@ praisonai/ui/realtime.py,sha256=aVK-lbA57J9KHo3Lrknk4aaO1V1tRkiKXr_01zWrl30,1784
69
70
  praisonai/ui/realtimeclient/__init__.py,sha256=zA2xa7rBUSw77wFkndJMQNNPqdH6ywQ3uf4WSYHjNfs,27513
70
71
  praisonai/ui/realtimeclient/realtimedocs.txt,sha256=hmgd8Uwy2SkjSndyyF_-ZOaNxiyHwGaQLGc67DvV-sI,26395
71
72
  praisonai/ui/realtimeclient/tools.py,sha256=IJOYwVOBW5Ocn5_iV9pFkmSKR3WU3YpX3kwF0I3jikQ,7855
72
- praisonai/ui/sql_alchemy.py,sha256=fPLPBJlrgV1_sRugirbNDCunqxqFB-CjV9TvCThU4nU,29686
73
+ praisonai/ui/sql_alchemy.py,sha256=ilWAWicUGja7ADbXW9_OgIYeyKNuAQ1ZI_RMqjmMI9k,29667
73
74
  praisonai/ui/tools.md,sha256=Ad3YH_ZCLMWlz3mDXllQnQ_S5l55LWqLdcZSh-EXrHI,3956
74
75
  praisonai/upload_vision.py,sha256=lMpFn993UiYVJxRNZQTmcbPbEajQ5TFKCNGK1Icn_hg,5253
75
76
  praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
76
- praisonai-2.2.18.dist-info/METADATA,sha256=wblnChfolLTcsCb5ig3U6_RPiwGb3N9IsdJs_xBkntk,4745
77
- praisonai-2.2.18.dist-info/WHEEL,sha256=dCzwOzx-VmbmLA5u8QpkARaxx3rsePBxa1nmZphhNQk,110
78
- praisonai-2.2.18.dist-info/entry_points.txt,sha256=I_xc6a6MNTTfLxYmAxe0rgey0G-_hbY07oFW-ZDnkw4,135
79
- praisonai-2.2.18.dist-info/RECORD,,
77
+ praisonai-2.2.20.dist-info/METADATA,sha256=RvvJoCdvKn21YpxRIRIhBxDkQ8B1NglhdXYL4aYhWeo,4739
78
+ praisonai-2.2.20.dist-info/WHEEL,sha256=dCzwOzx-VmbmLA5u8QpkARaxx3rsePBxa1nmZphhNQk,110
79
+ praisonai-2.2.20.dist-info/entry_points.txt,sha256=QSSfuXjZMhf16FZ201I_oSoX_s1nWYbi_4_UXPE3S-o,145
80
+ praisonai-2.2.20.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  [console_scripts]
2
2
  praisonai=praisonai.__main__:main
3
3
  praisonai-call=praisonai.api.call:main
4
- setup-conda-env=setup.setup_conda_env:main
4
+ setup-conda-env=praisonai.setup.setup_conda_env:main
5
5