diff --git a/Dockerfile b/Dockerfile index 711d3a42..589246dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file +CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"] diff --git a/api.py b/api.py index 1f5d3149..2903bd45 100644 --- a/api.py +++ b/api.py @@ -15,4 +15,4 @@ def home(): return f'{html_output}' if __name__ == "__main__": - app.run(debug=True) \ No newline at end of file + app.run(debug=True) diff --git a/praisonai/deploy.py b/praisonai/deploy.py index 5a3cda36..c754cc38 100644 --- a/praisonai/deploy.py +++ b/praisonai/deploy.py @@ -8,6 +8,32 @@ 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_output}'\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") @@ -15,6 +41,8 @@ def set_environment_variables(self): 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", diff --git a/pyproject.toml b/pyproject.toml index cddea367..b5b3db20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = ""