Skip to content

Commit 1ed429e

Browse files
Merge pull request #46 from MervinPraison/develop
v0.0.24
2 parents 9c0c72b + d8b75b2 commit 1ed429e

File tree

7 files changed

+78
-51
lines changed

7 files changed

+78
-51
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.11-slim
22
WORKDIR /app
33
COPY . .
4-
RUN pip install flask praisonai==0.0.23 gunicorn markdown
4+
RUN pip install flask praisonai==0.0.24 gunicorn markdown
55
EXPOSE 8080
66
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
project = 'PraisonAI'
1010
copyright = '2024, Mervin Praison'
1111
author = 'Mervin Praison'
12-
release = '0.0.23'
12+
release = '0.0.24'
1313

1414
# -- General configuration ---------------------------------------------------
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

praisonai/chainlit_ui.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
from chainlit.types import ThreadDict
66
from typing import Optional
7+
from dotenv import load_dotenv
78

89
framework = "crewai"
910
config_list = [
@@ -47,6 +48,13 @@ async def main(message: cl.Message):
4748
await msg.send()
4849
message_history.append({"role": "assistant", "content": message.content})
4950

51+
# Load environment variables from .env file
52+
load_dotenv()
53+
54+
# Get username and password from environment variables
55+
username = os.getenv("CHAINLIT_USERNAME", "admin") # Default to "admin" if not found
56+
password = os.getenv("CHAINLIT_PASSWORD", "admin") # Default to "admin" if not found
57+
5058
@cl.password_auth_callback
5159
def auth_callback(username: str, password: str):
5260
# Fetch the user matching username from your database

praisonai/cli.py

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@
99
load_dotenv()
1010
import autogen
1111
import gradio as gr
12-
import chainlit as cl
13-
import asyncio
14-
import uvicorn
15-
from chainlit.cli import cli as chainlit_cli
16-
from chainlit.server import app
1712
import argparse
1813
from .auto import AutoGenerator
1914
from .agents_generator import AgentsGenerator
2015
from .inbuilt_tools import *
2116

17+
try:
18+
from chainlit.cli import chainlit_run
19+
CHAINLIT_AVAILABLE = True
20+
except ImportError:
21+
CHAINLIT_AVAILABLE = False
22+
23+
try:
24+
import gradio as gr
25+
GRADIO_AVAILABLE = True
26+
except ImportError:
27+
GRADIO_AVAILABLE = False
28+
2229
class PraisonAI:
2330
def __init__(self, agent_file="agents.yaml", framework="", auto=False, init=False):
2431
"""
@@ -110,7 +117,10 @@ def main(self):
110117
elif args.ui == "chainlit":
111118
self.create_chainlit_interface()
112119
else:
113-
self.create_chainlit_interface()
120+
# Modify below code to allow default ui
121+
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
122+
result = agents_generator.generate_crew_and_kickoff()
123+
return result
114124
else:
115125
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
116126
result = agents_generator.generate_crew_and_kickoff()
@@ -135,7 +145,7 @@ def parse_args(self):
135145
"""
136146
parser = argparse.ArgumentParser(prog="praisonai", description="praisonAI command-line interface")
137147
parser.add_argument("--framework", choices=["crewai", "autogen"], help="Specify the framework")
138-
parser.add_argument("--ui", nargs='?', const='chainlit', default="chainlit", help="Specify the UI framework (gradio or chainlit). Default chainlit")
148+
parser.add_argument("--ui", choices=["chainlit", "gradio"], help="Specify the UI framework (gradio or chainlit).")
139149
parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
140150
parser.add_argument("--init", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
141151
parser.add_argument("agent_file", nargs="?", help="Specify the agent file")
@@ -165,40 +175,43 @@ def create_gradio_interface(self):
165175
Example:
166176
>>> praison_ai.create_gradio_interface()
167177
"""
168-
def generate_crew_and_kickoff_interface(auto_args, framework):
169-
"""
170-
Generate a crew and kick off tasks based on the provided auto arguments and framework.
171-
172-
Args:
173-
auto_args (list): Topic.
174-
framework (str): The framework to use for generating agents.
175-
176-
Returns:
177-
str: A string representing the result of generating the crew and kicking off tasks.
178-
179-
Raises:
180-
None: This method does not raise any exceptions.
181-
182-
Example:
183-
>>> result = generate_crew_and_kickoff_interface("Create a movie about Cat in Mars", "crewai")
184-
>>> print(result)
185-
"""
186-
self.framework = framework
187-
self.agent_file = "test.yaml"
188-
generator = AutoGenerator(topic=auto_args , framework=self.framework)
189-
self.agent_file = generator.generate()
190-
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
191-
result = agents_generator.generate_crew_and_kickoff()
192-
return result
193-
194-
gr.Interface(
195-
fn=generate_crew_and_kickoff_interface,
196-
inputs=[gr.Textbox(lines=2, label="Auto Args"), gr.Dropdown(choices=["crewai", "autogen"], label="Framework")],
197-
outputs="textbox",
198-
title="Praison AI Studio",
199-
description="Create Agents and perform tasks",
200-
theme="default"
201-
).launch()
178+
if GRADIO_AVAILABLE:
179+
def generate_crew_and_kickoff_interface(auto_args, framework):
180+
"""
181+
Generate a crew and kick off tasks based on the provided auto arguments and framework.
182+
183+
Args:
184+
auto_args (list): Topic.
185+
framework (str): The framework to use for generating agents.
186+
187+
Returns:
188+
str: A string representing the result of generating the crew and kicking off tasks.
189+
190+
Raises:
191+
None: This method does not raise any exceptions.
192+
193+
Example:
194+
>>> result = generate_crew_and_kickoff_interface("Create a movie about Cat in Mars", "crewai")
195+
>>> print(result)
196+
"""
197+
self.framework = framework
198+
self.agent_file = "test.yaml"
199+
generator = AutoGenerator(topic=auto_args , framework=self.framework)
200+
self.agent_file = generator.generate()
201+
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
202+
result = agents_generator.generate_crew_and_kickoff()
203+
return result
204+
205+
gr.Interface(
206+
fn=generate_crew_and_kickoff_interface,
207+
inputs=[gr.Textbox(lines=2, label="Auto Args"), gr.Dropdown(choices=["crewai", "autogen"], label="Framework")],
208+
outputs="textbox",
209+
title="Praison AI Studio",
210+
description="Create Agents and perform tasks",
211+
theme="default"
212+
).launch()
213+
else:
214+
print("ERROR: Gradio is not installed. Please install it with 'pip install \"praisonai[gradio]\"' to use this feature.")
202215

203216
def create_chainlit_interface(self):
204217
"""
@@ -211,10 +224,11 @@ def create_chainlit_interface(self):
211224
Returns:
212225
None: This function does not return any value. It starts the Chainlit application.
213226
"""
214-
from chainlit.cli import chainlit_run # Import chainlit_run
215-
os.environ["CHAINLIT_PORT"] = "8082"
216-
chainlit_run(["praisonai/chainlit_ui.py"])
217-
227+
if CHAINLIT_AVAILABLE:
228+
os.environ["CHAINLIT_PORT"] = "8082"
229+
chainlit_run(["praisonai/chainlit_ui.py"])
230+
else:
231+
print("ERROR: Chainlit is not installed. Please install it with 'pip install \"praisonai\[ui]\"' to use the UI.")
218232

219233
if __name__ == "__main__":
220234
praison_ai = PraisonAI()

praisonai/deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def create_dockerfile(self):
5656
file.write("FROM python:3.11-slim\n")
5757
file.write("WORKDIR /app\n")
5858
file.write("COPY . .\n")
59-
file.write("RUN pip install flask praisonai==0.0.23 gunicorn markdown\n")
59+
file.write("RUN pip install flask praisonai==0.0.24 gunicorn markdown\n")
6060
file.write("EXPOSE 8080\n")
6161
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
6262

pyproject.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "PraisonAI"
3-
version = "0.0.23"
3+
version = "0.0.24"
44
description = "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."
55
authors = ["Mervin Praison"]
66
license = ""
@@ -18,7 +18,6 @@ python = ">=3.10,<3.13"
1818
rich = ">=13.7"
1919
pyautogen = ">=0.2.19"
2020
crewai = ">=0.30.4"
21-
gradio = ">=4.26.0"
2221
Flask = ">=3.0.0"
2322
markdown = ">=3.5"
2423
crewai-tools = "^0.2.6"
@@ -33,4 +32,9 @@ requires = ["poetry-core"]
3332
build-backend = "poetry.core.masonry.api"
3433

3534
[tool.poetry.scripts]
36-
praisonai = "praisonai.__main__:main"
35+
praisonai = "praisonai.__main__:main"
36+
37+
[tool.poetry.extras]
38+
ui = ["chainlit>=1.1.301"]
39+
chainlit = ["chainlit>=1.1.301"]
40+
gradio = ["gradio>=4.26.0"]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ rich>=13.7
22
pyautogen>=0.2.19
33
crewai>=0.30.4
44
gradio>=4.20.0
5+
chainlit>=1.1.301
56
crewai_tools
67
duckduckgo_search
78
praisonai_tools

0 commit comments

Comments
 (0)