Skip to content

Commit

Permalink
Version 0.0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
MervinPraison committed Mar 26, 2024
1 parent 44bde8f commit 6ee0ff4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM python:3.11-slim
WORKDIR /app
# Copy only api.py and agents.yaml to /app in the container
COPY api.py agents.yaml ./
RUN pip install flask praisonai==0.0.16 gunicorn markdown
COPY . .
RUN pip install flask praisonai==0.0.17 gunicorn markdown
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
2 changes: 1 addition & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def home():
return f'<html><body>{html_output}</body></html>'

if __name__ == "__main__":
app.run(debug=True)
app.run(debug=True)
28 changes: 28 additions & 0 deletions praisonai/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,41 @@ def __init__(self):
load_dotenv()
self.set_environment_variables()

def create_dockerfile(self):
with open("Dockerfile", "w") as file:
file.write("FROM python:3.11-slim\n")
file.write("WORKDIR /app\n")
file.write("COPY . .\n")
file.write("RUN pip install flask praisonai==0.0.17 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')

def create_api_file(self):
with open("api.py", "w") as file:
file.write("from flask import Flask\n")
file.write("from praisonai import PraisonAI\n")
file.write("import markdown\n\n")
file.write("app = Flask(__name__)\n\n")
file.write("def basic():\n")
file.write(" praison_ai = PraisonAI(agent_file=\"agents.yaml\")\n")
file.write(" return praison_ai.main()\n\n")
file.write("@app.route('/')\n")
file.write("def home():\n")
file.write(" output = basic()\n")
file.write(" html_output = markdown.markdown(output)\n")
file.write(" return f'<html><body>{html_output}</body></html>'\n\n")
file.write("if __name__ == \"__main__\":\n")
file.write(" app.run(debug=True)\n")

def set_environment_variables(self):
"""Sets environment variables with fallback to .env values or defaults."""
os.environ["OPENAI_MODEL_NAME"] = os.getenv("OPENAI_MODEL_NAME", "gpt-4-turbo-preview")
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "Enter your API key")
os.environ["OPENAI_API_BASE"] = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")

def run_commands(self):
self.create_api_file()
self.create_dockerfile()
"""Runs a sequence of shell commands for deployment, continues on error."""
commands = [
"yes | gcloud auth configure-docker us-central1-docker.pkg.dev",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "praisonAI"
version = "0.0.16"
version = "0.0.17"
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."
authors = ["Mervin Praison"]
license = ""
Expand Down

0 comments on commit 6ee0ff4

Please sign in to comment.