Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

Write me the perfect prompt with all details to write a python app and deploy on ubuntu…

  1. User

    Write me the perfect prompt with all details to write a python app and deploy on ubuntu autogen, with the following functionality: follow the original documentation on this https://microsoft.github.io/autogen/docs/

  2. Assistant

    Certainly! Below is a comprehensive prompt that you can use to instruct an AI assistant to write a Python application and deploy it on Ubuntu using Microsoft Autogen, following the official documentation provided at https://microsoft.github.io/autogen/docs/.


    Prompt:


    Task Overview:

    Develop a Python application and deploy it on an Ubuntu server using Microsoft Autogen. The application and deployment process must strictly follow the guidelines and best practices outlined in the official Autogen documentation: https://microsoft.github.io/autogen/docs/.


    Requirements:

    1. Application Functionality:

      • Create a Python web application that performs the following:
        • Exposes a RESTful API endpoint at /generate-text.
        • Accepts a POST request with a JSON payload containing a prompt text, e.g., {"prompt": "Once upon a time"}.
        • Uses Microsoft Autogen to generate a continuation of the prompt text.
        • Returns the generated text in a JSON response, e.g., {"response": "Once upon a time, there was a brave knight who..."}.
    2. Technologies and Libraries:

      • Use Python 3.10 or later.
      • Utilize the FastAPI framework for building the web API.
      • Employ Uvicorn as the ASGI server.
      • Integrate Microsoft Autogen SDK for text generation as per the documentation.
      • Manage dependencies using pip and provide a requirements.txt file.
    3. Deployment Environment:

      • Target operating system: Ubuntu 22.04 LTS.
      • Containerization (if applicable): Use Docker to containerize the application.
      • Ensure the application runs as a systemd service for automatic start on boot (if not using Docker).
    4. Security and Best Practices:

      • Implement input validation to prevent injection attacks.
      • Handle exceptions and errors gracefully, returning appropriate HTTP status codes.
      • Use environment variables or a configuration file to manage sensitive settings and API keys.
      • Follow the security recommendations in the Autogen documentation.
    5. Documentation:

      • Provide inline comments within the code explaining key sections and logic.
      • Include a comprehensive README.md with:
        • An overview of the application.
        • Prerequisites and setup instructions.
        • Step-by-step deployment guide on Ubuntu using Autogen.
        • Instructions on how to test the API endpoints.
        • Troubleshooting tips and FAQs.
    6. Testing:

      • Write unit tests for the key functionalities using pytest.
      • Include instructions on how to run the tests.
      • Provide examples of API requests using curl or a tool like Postman.
    7. Deployment Steps:

      • Detail every step required to deploy the application on an Ubuntu server, including:
        • System updates and package installations.
        • Python environment setup.
        • Dependency installation.
        • Application configuration.
        • Setting up Autogen according to the documentation.
        • Starting the application and enabling it to run on startup.
    8. Compliance with Autogen Documentation:

      • Ensure that all features and functionalities utilize Autogen as per the guidelines.
      • Reference specific sections of the Autogen documentation where applicable.
      • Highlight any configurations or settings that are crucial for optimal performance.
    9. Additional Features (Optional):

      • Implement logging using Python's logging module.
      • Set up SSL/TLS for secure communication (provide instructions; implementation is optional depending on scope).
      • Include versioning for the API endpoint, e.g., /api/v1/generate-text.

    Deliverables:

    • Complete Python source code for the application.
    • requirements.txt file with all dependencies.
    • README.md with documentation and deployment instructions.
    • Unit tests and instructions on how to run them.
    • Any configuration files or scripts needed for deployment.

    Notes:

    • Assume the user has basic knowledge of Python and Ubuntu administration.
    • Provide clear and concise instructions, ensuring ease of understanding.
    • Ensure that the application is production-ready and scalable.
    • Prioritize security, efficiency, and adherence to best practices.

    By using this prompt, the AI assistant should be able to generate a comprehensive Python application along with all necessary instructions to deploy it on Ubuntu using Microsoft Autogen, strictly following the provided documentation.