PraisonAI 0.0.26__py3-none-any.whl → 0.0.28__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.

praisonai/auto.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from openai import OpenAI
2
2
  from pydantic import BaseModel
3
- from typing import Dict, List
3
+ from typing import Dict, List, Optional
4
4
  import instructor
5
5
  import os
6
6
  import json
@@ -23,16 +23,17 @@ class TeamStructure(BaseModel):
23
23
  roles: Dict[str, RoleDetails]
24
24
 
25
25
  class AutoGenerator:
26
- def __init__(self, topic="Movie Story writing about AI", agent_file="test.yaml", framework="crewai"):
26
+ def __init__(self, topic="Movie Story writing about AI", agent_file="test.yaml", framework="crewai", config_list: Optional[List[Dict]] = None):
27
27
  """
28
28
  Initialize the AutoGenerator class with the specified topic, agent file, and framework.
29
- note: autogen framework is different from this AutoGenerator class.
29
+ Note: autogen framework is different from this AutoGenerator class.
30
30
 
31
31
  Args:
32
32
  topic (str, optional): The topic for the generated team structure. Defaults to "Movie Story writing about AI".
33
33
  agent_file (str, optional): The name of the YAML file to save the generated team structure. Defaults to "test.yaml".
34
34
  framework (str, optional): The framework for the generated team structure. Defaults to "crewai".
35
-
35
+ config_list (Optional[List[Dict]], optional): A list containing the configuration details for the OpenAI API.
36
+ If None, it defaults to using environment variables or hardcoded values.
36
37
  Attributes:
37
38
  config_list (list): A list containing the configuration details for the OpenAI API.
38
39
  topic (str): The specified topic for the generated team structure.
@@ -40,10 +41,11 @@ class AutoGenerator:
40
41
  framework (str): The specified framework for the generated team structure.
41
42
  client (instructor.Client): An instance of the instructor.Client class initialized with the specified OpenAI API configuration.
42
43
  """
43
- self.config_list = [
44
+ self.config_list = config_list or [
44
45
  {
45
46
  'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
46
47
  'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
48
+ 'api_key': os.environ.get("OPENAI_API_KEY")
47
49
  }
48
50
  ]
49
51
  self.topic = topic
praisonai/chainlit_ui.py CHANGED
@@ -1,27 +1,162 @@
1
+ # praisonai/chainlit_ui.py
1
2
  from praisonai.agents_generator import AgentsGenerator
2
3
  from praisonai.auto import AutoGenerator
3
4
  import chainlit as cl
4
5
  import os
5
6
  from chainlit.types import ThreadDict
7
+ from chainlit.input_widget import Select, TextInput
6
8
  from typing import Optional
7
9
  from dotenv import load_dotenv
10
+ load_dotenv()
8
11
 
9
12
  framework = "crewai"
10
13
  config_list = [
11
14
  {
12
15
  'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
13
16
  'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
17
+ 'api_key': os.environ.get("OPENAI_API_KEY")
14
18
  }
15
19
  ]
16
20
  agent_file = "test.yaml"
17
21
 
22
+ actions=[
23
+ cl.Action(name="run", value="run", label="✅ Run"),
24
+ cl.Action(name="modify", value="modify", label="🔧 Modify"),
25
+ ]
26
+
27
+ @cl.action_callback("run")
28
+ async def on_run(action):
29
+ await main(cl.Message(content=""))
30
+
31
+ @cl.action_callback("modify")
32
+ async def on_modify(action):
33
+ await cl.Message(content="Modify the agents and tools from below settings").send()
34
+
35
+
36
+ @cl.set_chat_profiles
37
+ async def set_profiles(current_user: cl.User):
38
+ return [
39
+ cl.ChatProfile(
40
+ name="Auto",
41
+ markdown_description="Automatically generate agents and tasks based on your input.",
42
+ starters=[
43
+ cl.Starter(
44
+ label="Create a movie script",
45
+ message="Create a movie script about a futuristic society where AI and humans coexist, focusing on the conflict and resolution between them. Start with an intriguing opening scene.",
46
+ icon="/public/movie.svg",
47
+ ),
48
+ cl.Starter(
49
+ label="Design a fantasy world",
50
+ message="Design a detailed fantasy world with unique geography, cultures, and magical systems. Start by describing the main continent and its inhabitants.",
51
+ icon="/public/fantasy.svg",
52
+ ),
53
+ cl.Starter(
54
+ label="Write a futuristic political thriller",
55
+ message="Write a futuristic political thriller involving a conspiracy within a global government. Start with a high-stakes meeting that sets the plot in motion.",
56
+ icon="/public/thriller.svg",
57
+ ),
58
+ cl.Starter(
59
+ label="Develop a new board game",
60
+ message="Develop a new, innovative board game. Describe the game's objective, rules, and unique mechanics. Create a scenario to illustrate gameplay.",
61
+ icon="/public/game.svg",
62
+ ),
63
+ ]
64
+ ),
65
+ cl.ChatProfile(
66
+ name="Manual",
67
+ markdown_description="Manually define your agents and tasks using a YAML file.",
68
+ ),
69
+ ]
70
+
71
+
18
72
  @cl.on_chat_start
19
73
  async def start_chat():
20
74
  cl.user_session.set(
21
75
  "message_history",
22
76
  [{"role": "system", "content": "You are a helpful assistant."}],
23
77
  )
78
+ settings = await cl.ChatSettings(
79
+ [
80
+ TextInput(id="Model", label="OpenAI - Model", initial=config_list[0]['model']),
81
+ TextInput(id="BaseUrl", label="OpenAI - Base URL", initial=config_list[0]['base_url']),
82
+ TextInput(id="ApiKey", label="OpenAI - API Key", initial=config_list[0]['api_key']),
83
+ Select(
84
+ id="Framework",
85
+ label="Framework",
86
+ values=["crewai", "autogen"],
87
+ initial_index=0,
88
+ ),
89
+ ]
90
+ ).send()
91
+ cl.user_session.set("settings", settings)
92
+ chat_profile = cl.user_session.get("chat_profile")
93
+ if chat_profile=="Manual":
94
+
95
+ agent_file = "agents.yaml"
96
+ full_agent_file_path = os.path.abspath(agent_file) # Get full path
97
+ if os.path.exists(full_agent_file_path):
98
+ with open(full_agent_file_path, 'r') as f:
99
+ yaml_content = f.read()
100
+ msg = cl.Message(content=yaml_content, language="yaml")
101
+ await msg.send()
102
+
103
+
104
+ full_tools_file_path = os.path.abspath("tools.py") # Get full path
105
+ if os.path.exists(full_tools_file_path):
106
+ with open(full_tools_file_path, 'r') as f:
107
+ tools_content = f.read()
108
+ msg = cl.Message(content=tools_content, language="python")
109
+ await msg.send()
110
+
111
+ settings = await cl.ChatSettings(
112
+ [
113
+ TextInput(id="Model", label="OpenAI - Model", initial=config_list[0]['model']),
114
+ TextInput(id="BaseUrl", label="OpenAI - Base URL", initial=config_list[0]['base_url']),
115
+ TextInput(id="ApiKey", label="OpenAI - API Key", initial=config_list[0]['api_key']),
116
+ Select(
117
+ id="Framework",
118
+ label="Framework",
119
+ values=["crewai", "autogen"],
120
+ initial_index=0,
121
+ ),
122
+ TextInput(id="agents", label="agents.yaml", initial=yaml_content, multiline=True),
123
+ TextInput(id="tools", label="tools.py", initial=tools_content, multiline=True),
124
+ ]
125
+ ).send()
126
+ cl.user_session.set("settings", settings)
127
+
128
+ res = await cl.AskActionMessage(
129
+ content="Pick an action!",
130
+ actions=actions,
131
+ ).send()
132
+ if res and res.get("value") == "modify":
133
+ await cl.Message(content="Modify the agents and tools from below settings", actions=actions).send()
134
+ elif res and res.get("value") == "run":
135
+ await main(cl.Message(content="", actions=actions))
136
+
137
+ await on_settings_update(settings)
138
+
139
+ @cl.on_settings_update
140
+ async def on_settings_update(settings):
141
+ """Handle updates to the ChatSettings form."""
142
+ global config_list, framework
143
+ config_list[0]['model'] = settings["Model"]
144
+ config_list[0]['base_url'] = settings["BaseUrl"]
145
+ config_list[0]['api_key'] = settings["ApiKey"]
146
+ os.environ["OPENAI_API_KEY"] = config_list[0]['api_key']
147
+ os.environ["OPENAI_MODEL_NAME"] = config_list[0]['model']
148
+ os.environ["OPENAI_API_BASE"] = config_list[0]['base_url']
149
+ framework = settings["Framework"]
150
+
151
+ if "agents" in settings:
152
+ with open("agents.yaml", "w") as f:
153
+ f.write(settings["agents"])
154
+ if "tools" in settings:
155
+ with open("tools.py", "w") as f:
156
+ f.write(settings["tools"])
24
157
 
158
+ print("Settings updated")
159
+
25
160
  @cl.on_chat_resume
26
161
  async def on_chat_resume(thread: ThreadDict):
27
162
  message_history = cl.user_session.get("message_history", [])
@@ -33,20 +168,52 @@ async def on_chat_resume(thread: ThreadDict):
33
168
  message_history.append({"role": "assistant", "content": message["content"]})
34
169
  cl.user_session.set("message_history", message_history)
35
170
 
171
+ # @cl.step(type="tool")
172
+ # async def tool(data: Optional[str] = None, language: Optional[str] = None):
173
+ # return cl.Message(content=data, language=language)
174
+
36
175
  @cl.on_message
37
176
  async def main(message: cl.Message):
38
177
  """Run PraisonAI with the provided message as the topic."""
39
178
  message_history = cl.user_session.get("message_history")
40
179
  message_history.append({"role": "user", "content": message.content})
41
180
  topic = message.content
42
- agent_file = "test.yaml"
43
- generator = AutoGenerator(topic=topic, framework=framework)
44
- agent_file = generator.generate()
45
- agents_generator = AgentsGenerator(agent_file, framework, config_list)
46
- result = agents_generator.generate_crew_and_kickoff()
47
- msg = cl.Message(content=result)
48
- await msg.send()
49
- message_history.append({"role": "assistant", "content": message.content})
181
+ chat_profile = cl.user_session.get("chat_profile")
182
+
183
+ if chat_profile == "Auto":
184
+ agent_file = "agents.yaml"
185
+ generator = AutoGenerator(topic=topic, agent_file=agent_file, framework=framework, config_list=config_list)
186
+ agent_file = generator.generate()
187
+ agents_generator = AgentsGenerator(agent_file, framework, config_list)
188
+ result = agents_generator.generate_crew_and_kickoff()
189
+ msg = cl.Message(content=result)
190
+ await msg.send()
191
+ message_history.append({"role": "assistant", "content": message.content})
192
+ else: # chat_profile == "Manual"
193
+ agent_file = "agents.yaml"
194
+ full_agent_file_path = os.path.abspath(agent_file) # Get full path
195
+ full_tools_file_path = os.path.abspath("tools.py")
196
+ if os.path.exists(full_agent_file_path):
197
+ with open(full_agent_file_path, 'r') as f:
198
+ yaml_content = f.read()
199
+ # tool_res = await tool()
200
+ msg_agents = cl.Message(content=yaml_content, language="yaml")
201
+ await msg_agents.send()
202
+ if os.path.exists(full_tools_file_path):
203
+ with open(full_tools_file_path, 'r') as f:
204
+ tools_content = f.read()
205
+ msg_tools = cl.Message(content=tools_content, language="python")
206
+ await msg_tools.send()
207
+ else:
208
+ # If the file doesn't exist, follow the same process as "Auto"
209
+ generator = AutoGenerator(topic=topic, agent_file=agent_file, framework=framework, config_list=config_list)
210
+ agent_file = generator.generate()
211
+
212
+ agents_generator = AgentsGenerator(agent_file, framework, config_list)
213
+ result = agents_generator.generate_crew_and_kickoff()
214
+ msg = cl.Message(content=result, actions=actions)
215
+ await msg.send()
216
+ message_history.append({"role": "assistant", "content": message.content})
50
217
 
51
218
  # Load environment variables from .env file
52
219
  load_dotenv()
@@ -59,9 +226,9 @@ password = os.getenv("CHAINLIT_PASSWORD", "admin") # Default to "admin" if not
59
226
  def auth_callback(username: str, password: str):
60
227
  # Fetch the user matching username from your database
61
228
  # and compare the hashed password with the value stored in the database
62
- if (username, password) == ("admin", "admin"):
229
+ if (username, password) == (username, password):
63
230
  return cl.User(
64
- identifier="admin", metadata={"role": "admin", "provider": "credentials"}
231
+ identifier=username, metadata={"role": "ADMIN", "provider": "credentials"}
65
232
  )
66
233
  else:
67
- return None
234
+ return None
praisonai/cli.py CHANGED
@@ -47,6 +47,7 @@ class PraisonAI:
47
47
  {
48
48
  'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
49
49
  'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
50
+ 'api_key': os.environ.get("OPENAI_API_KEY")
50
51
  }
51
52
  ]
52
53
  self.agent_file = agent_file
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.26 gunicorn markdown\n")
59
+ file.write("RUN pip install flask praisonai==0.0.28 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/test.py CHANGED
@@ -9,6 +9,7 @@ config_list = [
9
9
  {
10
10
  'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-3.5-turbo"),
11
11
  'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
12
+ 'api_key': os.environ.get("OPENAI_API_KEY")
12
13
  }
13
14
  ]
14
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PraisonAI
3
- Version: 0.0.26
3
+ Version: 0.0.28
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
@@ -0,0 +1,16 @@
1
+ praisonai/__init__.py,sha256=5SwxMGd4vNUmYedF_HLLQBo4u8zMEWuEfKhHqJrEE1I,59
2
+ praisonai/__main__.py,sha256=MVgsjMThjBexHt4nhd760JCqvP4x0IQcwo8kULOK4FQ,144
3
+ praisonai/agents_generator.py,sha256=blzU5uru7rctRUTlnxEER9NLyu4aAd-oUjE-0xo81ww,12787
4
+ praisonai/auto.py,sha256=CpE9zUbdCP1wR0aLZWKVLxiLU9JOQprRNBK9WKDZVQo,7758
5
+ praisonai/chainlit_ui.py,sha256=jXNQfnH3D2xsSvJ0ESuHy-yDgBjudBKb1ODPfbqhYRc,10053
6
+ praisonai/cli.py,sha256=_KB_12VoYFSLywFqE0kfbkM76e3DNRK9eeWsFlnfANc,10021
7
+ praisonai/deploy.py,sha256=t8JLpY4Zq4GBlOogjI2cLKyjIq2_xOVsqLguQrhtE3M,6031
8
+ praisonai/inbuilt_tools/__init__.py,sha256=mUKnbL6Gram9c9f2m8wJwEzURBLmPEOcHzwySBH89YA,74
9
+ praisonai/inbuilt_tools/autogen_tools.py,sha256=m3Ws2444hzgkiEjqw9Y4PFb_LsU9ZDD23C03uNsyeu0,14556
10
+ praisonai/test.py,sha256=RZKq3UEFb6AnFFiHER3zBXfNmlteSLBlrTmOvnpnZLo,4092
11
+ praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
12
+ praisonai-0.0.28.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
13
+ praisonai-0.0.28.dist-info/METADATA,sha256=zYoPjpI0HpZ6RfcHI6IzzrEaelO_z4vyNz_C-ZfqyiY,9552
14
+ praisonai-0.0.28.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
15
+ praisonai-0.0.28.dist-info/entry_points.txt,sha256=Qg41eW3A1-dvdV5tF7LqChfYof8Rihk2rN1fiEE3vnk,53
16
+ praisonai-0.0.28.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- praisonai/__init__.py,sha256=5SwxMGd4vNUmYedF_HLLQBo4u8zMEWuEfKhHqJrEE1I,59
2
- praisonai/__main__.py,sha256=MVgsjMThjBexHt4nhd760JCqvP4x0IQcwo8kULOK4FQ,144
3
- praisonai/agents_generator.py,sha256=blzU5uru7rctRUTlnxEER9NLyu4aAd-oUjE-0xo81ww,12787
4
- praisonai/auto.py,sha256=evK0RxnR89e-HBTZD0fyJSD_m9k6rNj1Cmdn7dZKZ7A,7378
5
- praisonai/chainlit_ui.py,sha256=vOI6zPmQBD7OQJBMcmz-yuc1Hrs1QiO9cdgHcEZc8l4,2610
6
- praisonai/cli.py,sha256=rOQPALmdQBn1kbM5q9lpjRz4yfcWPybBRQ0ExeDCKqU,9961
7
- praisonai/deploy.py,sha256=4-OxTeU7I3I4dTZtvp8esmIFKjTmqA3I-BHLor9_U8A,6031
8
- praisonai/inbuilt_tools/__init__.py,sha256=mUKnbL6Gram9c9f2m8wJwEzURBLmPEOcHzwySBH89YA,74
9
- praisonai/inbuilt_tools/autogen_tools.py,sha256=m3Ws2444hzgkiEjqw9Y4PFb_LsU9ZDD23C03uNsyeu0,14556
10
- praisonai/test.py,sha256=DkS_z3w7TmXt9lc57ToYQzdKN2IkWqXEMDBYUmZiGNk,4040
11
- praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
12
- praisonai-0.0.26.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
13
- praisonai-0.0.26.dist-info/METADATA,sha256=moxTdew9K_So-jIuaETixmrozyt7yUFGGnpx41F88lU,9552
14
- praisonai-0.0.26.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
15
- praisonai-0.0.26.dist-info/entry_points.txt,sha256=Qg41eW3A1-dvdV5tF7LqChfYof8Rihk2rN1fiEE3vnk,53
16
- praisonai-0.0.26.dist-info/RECORD,,