Skip to content

Commit e0ea6f8

Browse files
Merge pull request #49 from MervinPraison/develop
v0.0.27
2 parents 7b8a7aa + 1504369 commit e0ea6f8

File tree

10 files changed

+57
-18
lines changed

10 files changed

+57
-18
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.26 gunicorn markdown
4+
RUN pip install flask praisonai==0.0.27 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.26'
12+
release = '7'
1313

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

docs/ui.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,13 @@ CHAINLIT_USERNAME=admin
2626
pip install gradio
2727
export OPENAI_API_KEY="Enter your API key"
2828
praisonai --ui gradio
29+
```
30+
31+
## Streamlit
32+
33+
```
34+
git clone https://github.com/leporejoseph/PraisonAi-Streamlit
35+
cd PraisonAi-Streamlit
36+
pip install -r requirements.txt
37+
streamlit run app.py
2938
```

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

praisonai/auto.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from openai import OpenAI
22
from pydantic import BaseModel
3-
from typing import Dict, List
3+
from typing import Dict, List, Optional
44
import instructor
55
import os
66
import json
@@ -23,27 +23,29 @@ class TeamStructure(BaseModel):
2323
roles: Dict[str, RoleDetails]
2424

2525
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):
2727
"""
2828
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.
3030
3131
Args:
3232
topic (str, optional): The topic for the generated team structure. Defaults to "Movie Story writing about AI".
3333
agent_file (str, optional): The name of the YAML file to save the generated team structure. Defaults to "test.yaml".
3434
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.
3637
Attributes:
3738
config_list (list): A list containing the configuration details for the OpenAI API.
3839
topic (str): The specified topic for the generated team structure.
3940
agent_file (str): The specified name of the YAML file to save the generated team structure.
4041
framework (str): The specified framework for the generated team structure.
4142
client (instructor.Client): An instance of the instructor.Client class initialized with the specified OpenAI API configuration.
4243
"""
43-
self.config_list = [
44+
self.config_list = config_list or [
4445
{
4546
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
4647
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
48+
'api_key': os.environ.get("OPENAI_API_KEY")
4749
}
4850
]
4951
self.topic = topic

praisonai/chainlit_ui.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
# praisonai/chainlit_ui.py
12
from praisonai.agents_generator import AgentsGenerator
23
from praisonai.auto import AutoGenerator
34
import chainlit as cl
45
import os
56
from chainlit.types import ThreadDict
7+
from chainlit.input_widget import Select, TextInput
68
from typing import Optional
79
from dotenv import load_dotenv
10+
load_dotenv()
811

912
framework = "crewai"
1013
config_list = [
1114
{
1215
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
1316
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
17+
'api_key': os.environ.get("OPENAI_API_KEY")
1418
}
1519
]
1620
agent_file = "test.yaml"
@@ -21,7 +25,29 @@ async def start_chat():
2125
"message_history",
2226
[{"role": "system", "content": "You are a helpful assistant."}],
2327
)
28+
settings = await cl.ChatSettings(
29+
[
30+
TextInput(id="Model", label="OpenAI - Model", initial=config_list[0]['model']),
31+
TextInput(id="BaseUrl", label="OpenAI - Base URL", initial=config_list[0]['base_url']),
32+
Select(
33+
id="Framework",
34+
label="Framework",
35+
values=["crewai", "autogen"],
36+
initial_index=0,
37+
),
38+
]
39+
).send()
40+
# await on_settings_update(settings)
2441

42+
@cl.on_settings_update
43+
async def on_settings_update(settings):
44+
"""Handle updates to the ChatSettings form."""
45+
global config_list, framework
46+
config_list[0]['model'] = settings["Model"]
47+
config_list[0]['base_url'] = settings["BaseUrl"]
48+
framework = settings["Framework"]
49+
print("Settings updated:", settings)
50+
2551
@cl.on_chat_resume
2652
async def on_chat_resume(thread: ThreadDict):
2753
message_history = cl.user_session.get("message_history", [])
@@ -40,7 +66,7 @@ async def main(message: cl.Message):
4066
message_history.append({"role": "user", "content": message.content})
4167
topic = message.content
4268
agent_file = "test.yaml"
43-
generator = AutoGenerator(topic=topic, framework=framework)
69+
generator = AutoGenerator(topic=topic, framework=framework, config_list=config_list)
4470
agent_file = generator.generate()
4571
agents_generator = AgentsGenerator(agent_file, framework, config_list)
4672
result = agents_generator.generate_crew_and_kickoff()
@@ -59,9 +85,9 @@ async def main(message: cl.Message):
5985
def auth_callback(username: str, password: str):
6086
# Fetch the user matching username from your database
6187
# and compare the hashed password with the value stored in the database
62-
if (username, password) == ("admin", "admin"):
88+
if (username, password) == (username, password):
6389
return cl.User(
64-
identifier="admin", metadata={"role": "admin", "provider": "credentials"}
90+
identifier=username, metadata={"role": "ADMIN", "provider": "credentials"}
6591
)
6692
else:
6793
return None

praisonai/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(self, agent_file="agents.yaml", framework="", auto=False, init=Fals
4747
{
4848
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"),
4949
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
50+
'api_key': os.environ.get("OPENAI_API_KEY")
5051
}
5152
]
5253
self.agent_file = agent_file

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.26 gunicorn markdown\n")
59+
file.write("RUN pip install flask praisonai==0.0.27 gunicorn markdown\n")
6060
file.write("EXPOSE 8080\n")
6161
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
6262

praisonai/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{
1010
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-3.5-turbo"),
1111
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
12+
'api_key': os.environ.get("OPENAI_API_KEY")
1213
}
1314
]
1415

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "PraisonAI"
3-
version = "0.0.26"
3+
version = "0.0.27"
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 = ""

0 commit comments

Comments
 (0)