PraisonAI 0.0.37__py3-none-any.whl → 0.0.39__py3-none-any.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.

@@ -18,6 +18,7 @@ from praisonai_tools import (
18
18
  YoutubeVideoSearchTool
19
19
  )
20
20
  from .inbuilt_tools import *
21
+ from .inc import PraisonAIModel
21
22
  import inspect
22
23
  from pathlib import Path
23
24
  import importlib
@@ -46,7 +47,7 @@ def disable_crewai_telemetry():
46
47
  disable_crewai_telemetry()
47
48
 
48
49
  class AgentsGenerator:
49
- def __init__(self, agent_file, framework, config_list, log_level=None, agent_callback=None, task_callback=None):
50
+ def __init__(self, agent_file, framework, config_list, log_level=None, agent_callback=None, task_callback=None, agent_yaml=None):
50
51
  """
51
52
  Initialize the AgentsGenerator object.
52
53
 
@@ -57,6 +58,7 @@ class AgentsGenerator:
57
58
  log_level (int, optional): The logging level to use. Defaults to logging.INFO.
58
59
  agent_callback (callable, optional): A callback function to be executed after each agent step.
59
60
  task_callback (callable, optional): A callback function to be executed after each tool run.
61
+ agent_yaml (str, optional): The content of the YAML file. Defaults to None.
60
62
 
61
63
  Attributes:
62
64
  agent_file (str): The path to the agent file.
@@ -72,6 +74,7 @@ class AgentsGenerator:
72
74
  self.log_level = log_level
73
75
  self.agent_callback = agent_callback
74
76
  self.task_callback = task_callback
77
+ self.agent_yaml = agent_yaml
75
78
  self.log_level = log_level or logging.getLogger().getEffectiveLevel()
76
79
  if self.log_level == logging.NOTSET:
77
80
  self.log_level = os.environ.get('LOGLEVEL', 'INFO').upper()
@@ -169,14 +172,17 @@ class AgentsGenerator:
169
172
 
170
173
  This function first loads the agent configuration from the specified file. It then initializes the tools required for the agents based on the specified framework. If the specified framework is "autogen", it loads the LLM configuration dynamically and creates an AssistantAgent for each role in the configuration. It then adds tools to the agents if specified in the configuration. Finally, it prepares tasks for the agents based on the configuration and initiates the tasks using the crew of agents. If the specified framework is not "autogen", it creates a crew of agents and initiates tasks based on the configuration.
171
174
  """
172
- if self.agent_file == '/app/api:app' or self.agent_file == 'api:app':
173
- self.agent_file = 'agents.yaml'
174
- try:
175
- with open(self.agent_file, 'r') as f:
176
- config = yaml.safe_load(f)
177
- except FileNotFoundError:
178
- print(f"File not found: {self.agent_file}")
179
- return
175
+ if self.agent_yaml:
176
+ config = yaml.safe_load(self.agent_yaml)
177
+ else:
178
+ if self.agent_file == '/app/api:app' or self.agent_file == 'api:app':
179
+ self.agent_file = 'agents.yaml'
180
+ try:
181
+ with open(self.agent_file, 'r') as f:
182
+ config = yaml.safe_load(f)
183
+ except FileNotFoundError:
184
+ print(f"File not found: {self.agent_file}")
185
+ return
180
186
 
181
187
  topic = config['topic']
182
188
  tools_dict = {
@@ -270,7 +276,7 @@ class AgentsGenerator:
270
276
  result = "### Output ###\n"+response[-1].summary if hasattr(response[-1], 'summary') else ""
271
277
  if agentops_exists:
272
278
  agentops.end_session("Success")
273
- else:
279
+ else: # framework=crewai
274
280
  if agentops_exists:
275
281
  agentops.init(os.environ.get("AGENTOPS_API_KEY"), tags=["crewai"])
276
282
  for role, details in config['roles'].items():
@@ -280,7 +286,40 @@ class AgentsGenerator:
280
286
 
281
287
  # Adding tools to the agent if exists
282
288
  agent_tools = [tools_dict[tool] for tool in details.get('tools', []) if tool in tools_dict]
283
- agent = Agent(role=role_filled, goal=goal_filled, backstory=backstory_filled, tools=agent_tools, allow_delegation=False)
289
+
290
+ llm_model = details.get('llm') # Get the llm configuration
291
+ if llm_model:
292
+ llm = PraisonAIModel(
293
+ model=llm_model.get("model", os.environ.get("MODEL_NAME", "openai/gpt-4o")),
294
+ ).get_model()
295
+ else:
296
+ llm = PraisonAIModel().get_model()
297
+
298
+ function_calling_llm_model = details.get('function_calling_llm')
299
+ if function_calling_llm_model:
300
+ function_calling_llm = PraisonAIModel(
301
+ model=function_calling_llm_model.get("model", os.environ.get("MODEL_NAME", "openai/gpt-4o")),
302
+ ).get_model()
303
+ else:
304
+ function_calling_llm = PraisonAIModel().get_model()
305
+
306
+ agent = Agent(
307
+ role=role_filled,
308
+ goal=goal_filled,
309
+ backstory=backstory_filled,
310
+ tools=agent_tools,
311
+ allow_delegation=details.get('allow_delegation', False),
312
+ llm=llm,
313
+ function_calling_llm=function_calling_llm,
314
+ max_iter=details.get('max_iter', 15),
315
+ max_rpm=details.get('max_rpm'),
316
+ max_execution_time=details.get('max_execution_time'),
317
+ verbose=details.get('verbose', True),
318
+ cache=details.get('cache', True),
319
+ system_template=details.get('system_template'),
320
+ prompt_template=details.get('prompt_template'),
321
+ response_template=details.get('response_template'),
322
+ )
284
323
 
285
324
  # Set agent callback if provided
286
325
  if self.agent_callback:
praisonai/auto.py CHANGED
@@ -6,6 +6,8 @@ import os
6
6
  import json
7
7
  import yaml
8
8
  from rich import print
9
+ import logging
10
+ logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper(), format='%(asctime)s - %(levelname)s - %(message)s')
9
11
 
10
12
  # Define Pydantic models outside of the generate method
11
13
  class TaskDetails(BaseModel):
praisonai/chainlit_ui.py CHANGED
@@ -10,6 +10,8 @@ from dotenv import load_dotenv
10
10
  load_dotenv()
11
11
  from contextlib import redirect_stdout
12
12
  from io import StringIO
13
+ import logging
14
+ logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper(), format='%(asctime)s - %(levelname)s - %(message)s')
13
15
 
14
16
  framework = "crewai"
15
17
  config_list = [
praisonai/cli.py CHANGED
@@ -29,7 +29,7 @@ except ImportError:
29
29
  GRADIO_AVAILABLE = False
30
30
 
31
31
  class PraisonAI:
32
- def __init__(self, agent_file="agents.yaml", framework="", auto=False, init=False):
32
+ def __init__(self, agent_file="agents.yaml", framework="", auto=False, init=False, agent_yaml=None):
33
33
  """
34
34
  Initialize the PraisonAI object with default parameters.
35
35
 
@@ -45,7 +45,9 @@ class PraisonAI:
45
45
  framework (str): The framework to use.
46
46
  auto (bool): A flag indicating whether to enable auto mode.
47
47
  init (bool): A flag indicating whether to enable initialization mode.
48
+ agent_yaml (str, optional): The content of the YAML file. Defaults to None.
48
49
  """
50
+ self.agent_yaml = agent_yaml
49
51
  self.config_list = [
50
52
  {
51
53
  'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
@@ -121,11 +123,11 @@ class PraisonAI:
121
123
  self.create_chainlit_interface()
122
124
  else:
123
125
  # Modify below code to allow default ui
124
- agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
126
+ agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list, agent_yaml=self.agent_yaml)
125
127
  result = agents_generator.generate_crew_and_kickoff()
126
128
  return result
127
129
  else:
128
- agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
130
+ agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list, agent_yaml=self.agent_yaml)
129
131
  result = agents_generator.generate_crew_and_kickoff()
130
132
  return result
131
133
 
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.37 gunicorn markdown\n")
59
+ file.write("RUN pip install flask praisonai==0.0.39 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,2 @@
1
+ # praisonai/inc/__init__.py
2
+ from .models import PraisonAIModel
@@ -0,0 +1,124 @@
1
+ # praisonai/inc/models.py
2
+ import os
3
+ import logging
4
+ logger = logging.getLogger(__name__)
5
+ logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper(), format='%(asctime)s - %(levelname)s - %(message)s')
6
+
7
+ # Conditionally import modules based on availability
8
+ try:
9
+ from langchain_openai import ChatOpenAI # pip install langchain-openai
10
+ OPENAI_AVAILABLE = True
11
+ except ImportError:
12
+ OPENAI_AVAILABLE = False
13
+
14
+ try:
15
+ from langchain_google_genai import ChatGoogleGenerativeAI # pip install langchain-google-genai
16
+ GOOGLE_GENAI_AVAILABLE = True
17
+ except ImportError:
18
+ GOOGLE_GENAI_AVAILABLE = False
19
+
20
+ try:
21
+ from langchain_anthropic import ChatAnthropic # pip install langchain-anthropic
22
+ ANTHROPIC_AVAILABLE = True
23
+ except ImportError:
24
+ ANTHROPIC_AVAILABLE = False
25
+
26
+ try:
27
+ from langchain_cohere import ChatCohere # pip install langchain-cohere
28
+ COHERE_AVAILABLE = True
29
+ except ImportError:
30
+ COHERE_AVAILABLE = False
31
+
32
+ class PraisonAIModel:
33
+ def __init__(self, model=None, api_key_var=None, base_url=None):
34
+ """
35
+ Initializes the PraisonAIModel with the provided parameters or environment variables.
36
+
37
+ Args:
38
+ model (str, optional): The name of the OpenAI model. Defaults to None.
39
+ api_key_var (str, optional): The OpenAI API key. Defaults to None.
40
+ base_url (str, optional): The base URL for the OpenAI API. Defaults to None.
41
+ """
42
+ self.model = model or os.getenv("OPENAI_MODEL_NAME", "gpt-4o")
43
+ if self.model.startswith("openai/"):
44
+ self.api_key_var = "OPENAI_API_KEY"
45
+ self.base_url = base_url or "https://api.openai.com/v1"
46
+ self.model_name = self.model.replace("openai/", "")
47
+ elif self.model.startswith("groq/"):
48
+ self.api_key_var = "GROQ_API_KEY"
49
+ self.base_url = base_url or "https://api.groq.com/openai/v1"
50
+ self.model_name = self.model.replace("groq/", "")
51
+ elif self.model.startswith("cohere/"):
52
+ self.api_key_var = "COHERE_API_KEY"
53
+ self.base_url = ""
54
+ self.model_name = self.model.replace("cohere/", "")
55
+ elif self.model.startswith("ollama/"):
56
+ self.api_key_var = "OLLAMA_API_KEY"
57
+ self.base_url = base_url or "http://localhost:11434/v1"
58
+ self.model_name = self.model.replace("ollama/", "")
59
+ elif self.model.startswith("anthropic/"):
60
+ self.api_key_var = "ANTHROPIC_API_KEY"
61
+ self.base_url = ""
62
+ self.model_name = self.model.replace("anthropic/", "")
63
+ elif self.model.startswith("google/"):
64
+ self.api_key_var = "GOOGLE_API_KEY"
65
+ self.base_url = ""
66
+ self.model_name = self.model.replace("google/", "")
67
+ else:
68
+ self.api_key_var = api_key_var or "OPENAI_API_KEY"
69
+ self.base_url = base_url or os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
70
+ self.model_name = self.model
71
+ logger.debug(f"Initialized PraisonAIModel with model {self.model_name}, api_key_var {self.api_key_var}, and base_url {self.base_url}")
72
+ self.api_key = os.environ.get(self.api_key_var, "nokey")
73
+
74
+ def get_model(self):
75
+ """
76
+ Returns an instance of the langchain Chat client with the configured parameters.
77
+
78
+ Returns:
79
+ Chat: An instance of the langchain Chat client.
80
+ """
81
+ if self.model.startswith("google/"):
82
+ if GOOGLE_GENAI_AVAILABLE:
83
+ return ChatGoogleGenerativeAI(
84
+ model=self.model_name,
85
+ google_api_key=self.api_key
86
+ )
87
+ else:
88
+ raise ImportError(
89
+ "Required Langchain Integration 'langchain-google-genai' not found. "
90
+ "Please install with 'pip install langchain-google-genai'"
91
+ )
92
+ elif self.model.startswith("cohere/"):
93
+ if COHERE_AVAILABLE:
94
+ return ChatCohere(
95
+ model=self.model_name,
96
+ cohere_api_key=self.api_key,
97
+ )
98
+ else:
99
+ raise ImportError(
100
+ "Required Langchain Integration 'langchain-cohere' not found. "
101
+ "Please install with 'pip install langchain-cohere'"
102
+ )
103
+ elif self.model.startswith("anthropic/"):
104
+ if ANTHROPIC_AVAILABLE:
105
+ return ChatAnthropic(
106
+ model=self.model_name,
107
+ anthropic_api_key=self.api_key,
108
+ )
109
+ else:
110
+ raise ImportError(
111
+ "Required Langchain Integration 'langchain-anthropic' not found. "
112
+ "Please install with 'pip install langchain-anthropic'"
113
+ )
114
+ elif OPENAI_AVAILABLE:
115
+ return ChatOpenAI(
116
+ model=self.model_name,
117
+ api_key=self.api_key,
118
+ base_url=self.base_url,
119
+ )
120
+ else:
121
+ raise ImportError(
122
+ "Required Langchain Integration 'langchain-openai' not found. "
123
+ "Please install with 'pip install langchain-openai'"
124
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PraisonAI
3
- Version: 0.0.37
3
+ Version: 0.0.39
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
@@ -9,14 +9,22 @@ Classifier: Programming Language :: Python :: 3.10
9
9
  Classifier: Programming Language :: Python :: 3.11
10
10
  Classifier: Programming Language :: Python :: 3.12
11
11
  Provides-Extra: agentops
12
+ Provides-Extra: anthropic
12
13
  Provides-Extra: api
14
+ Provides-Extra: cohere
15
+ Provides-Extra: google
13
16
  Provides-Extra: gradio
17
+ Provides-Extra: openai
14
18
  Provides-Extra: ui
15
- Requires-Dist: agentops (==0.2.3) ; extra == "agentops"
19
+ Requires-Dist: agentops (>=0.2.6) ; extra == "agentops"
16
20
  Requires-Dist: chainlit (>=1.1.301,<2.0.0) ; extra == "ui"
17
21
  Requires-Dist: crewai (>=0.32.0)
18
22
  Requires-Dist: flask (>=3.0.0) ; extra == "api"
19
23
  Requires-Dist: gradio (>=4.26.0) ; extra == "gradio"
24
+ Requires-Dist: langchain-anthropic (>=0.1.13) ; extra == "anthropic"
25
+ Requires-Dist: langchain-cohere (>=0.1.4) ; extra == "cohere"
26
+ Requires-Dist: langchain-google-genai (>=1.0.4) ; extra == "google"
27
+ Requires-Dist: langchain-openai (>=0.1.7) ; extra == "openai"
20
28
  Requires-Dist: markdown (>=3.5)
21
29
  Requires-Dist: praisonai-tools (>=0.0.7)
22
30
  Requires-Dist: pyautogen (>=0.2.19)
@@ -357,4 +365,6 @@ OPENAI_API_KEY=your-mistral-api-key
357
365
  - Submit a pull request via GitHub's web interface.
358
366
  - Await feedback from project maintainers.
359
367
 
368
+ ## Star History
360
369
 
370
+ [![Star History Chart](https://api.star-history.com/svg?repos=MervinPraison/PraisonAI&type=Date)](https://docs.praison.ai)
@@ -1,20 +1,22 @@
1
1
  praisonai/__init__.py,sha256=JrgyPlzZfLlozoW7SHZ1nVJ63rLPR3ki2k5ZPywYrnI,175
2
2
  praisonai/__main__.py,sha256=MVgsjMThjBexHt4nhd760JCqvP4x0IQcwo8kULOK4FQ,144
3
- praisonai/agents_generator.py,sha256=K4I5o7UliVhIb9nSFoGsCsJpPe7Cxtsg4Mflgtp2pHE,15030
4
- praisonai/auto.py,sha256=CpE9zUbdCP1wR0aLZWKVLxiLU9JOQprRNBK9WKDZVQo,7758
5
- praisonai/chainlit_ui.py,sha256=uXo7KTuOH09cu_rLU5RU5JLVCKSc9FM5IcpuW_SVG90,12079
6
- praisonai/cli.py,sha256=W_PL7bWnEEuFYBT24mh8171f7TiE_LdxVfrM16fp7Pc,10868
7
- praisonai/deploy.py,sha256=mQkAIR4X3ZWQCgX-EIJ3rKPeft9bH4cnCj5IriHHG9o,6031
3
+ praisonai/agents_generator.py,sha256=DoRYanu16HIAcmIcxiWeHaklfY_IaFb3CUoqBvhOh4A,16930
4
+ praisonai/auto.py,sha256=9spTXqj47Hmmqv5QHRYE_RzSVHH_KoPbaZjskUj2UcE,7895
5
+ praisonai/chainlit_ui.py,sha256=bNR7s509lp0I9JlJNvwCZRUZosC64qdvlFCt8NmFamQ,12216
6
+ praisonai/cli.py,sha256=cwuXGubuac7yTeiqx5o5S7ZN7erZAfe-6p35b3HM5SU,11066
7
+ praisonai/deploy.py,sha256=suxuznJ9YRBG9NjMMR5lEVjSTIS_27dcy5ACaYaiZtU,6031
8
8
  praisonai/inbuilt_tools/__init__.py,sha256=mUKnbL6Gram9c9f2m8wJwEzURBLmPEOcHzwySBH89YA,74
9
9
  praisonai/inbuilt_tools/autogen_tools.py,sha256=svYkM2N7DVFvbiwgoAS7U_MqTOD8rHf8VD3BaFUV5_Y,14907
10
+ praisonai/inc/__init__.py,sha256=sPDlYBBwdk0VlWzaaM_lG0_LD07lS2HRGvPdxXJFiYg,62
11
+ praisonai/inc/models.py,sha256=ySFxObHtuPxnmhjmx4MrFY86dH8h3xthLGzGW7XRr08,5207
10
12
  praisonai/public/fantasy.svg,sha256=4Gs3kIOux-pjGtw6ogI_rv5_viVJxnE5gRwGilsSg0o,1553
11
13
  praisonai/public/game.svg,sha256=y2QMaA01m8XzuDjTOBWzupOC3-TpnUl9ah89mIhviUw,2406
12
14
  praisonai/public/movie.svg,sha256=aJ2EQ8vXZusVsF2SeuAVxP4RFJzQ14T26ejrGYdBgzk,1289
13
15
  praisonai/public/thriller.svg,sha256=2dYY72EcgbEyTxS4QzjAm37Y4srtPWEW4vCMFki98ZI,3163
14
16
  praisonai/test.py,sha256=RZKq3UEFb6AnFFiHER3zBXfNmlteSLBlrTmOvnpnZLo,4092
15
17
  praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
16
- praisonai-0.0.37.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
17
- praisonai-0.0.37.dist-info/METADATA,sha256=Xpz7nJpDWwWqRC69QYlUVUwv2ecyxdATFgwkhjxhYw0,10359
18
- praisonai-0.0.37.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
19
- praisonai-0.0.37.dist-info/entry_points.txt,sha256=Qg41eW3A1-dvdV5tF7LqChfYof8Rihk2rN1fiEE3vnk,53
20
- praisonai-0.0.37.dist-info/RECORD,,
18
+ praisonai-0.0.39.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
19
+ praisonai-0.0.39.dist-info/METADATA,sha256=OHIsvAkxdbEEXGMtAijYIspkd71u8a-XXjAP9cuebBA,10854
20
+ praisonai-0.0.39.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
21
+ praisonai-0.0.39.dist-info/entry_points.txt,sha256=Qg41eW3A1-dvdV5tF7LqChfYof8Rihk2rN1fiEE3vnk,53
22
+ praisonai-0.0.39.dist-info/RECORD,,