### Application Startup Logs Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Example output logs when starting the application server. ```console [2024-10-10 13:19:18 +0530] [23635] [INFO] Starting gunicorn 23.0.0 [2024-10-10 13:19:18 +0530] [23635] [INFO] Listening at: http://127.0.0.1:8000 (23635) [2024-10-10 13:19:18 +0530] [23635] [INFO] Using worker: sync [2024-10-10 13:19:18 +0530] [23645] [INFO] Booting worker with pid: 23645 ``` -------------------------------- ### Setup Documentation Environment Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/contributing/docs.md Commands to initialize, activate, and install dependencies for local documentation development. ```bash python -m venv venv ``` ```bash source venv/bin/activate ``` ```bash pip install ".[devdocs]" ``` ```bash mkdocs serve ``` -------------------------------- ### Install and Run with Waitress on Windows Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Install Waitress via pip and start the application server on Windows. ```console pip install waitress waitress-serve --listen=0.0.0.0:8000 main:app ``` -------------------------------- ### Run env + pip Setup (Linux/MacOS) Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi_nats/index.md Commands to initialize the NATS container and start the application services on Unix-based systems. ```bash docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf ``` ```bash pip install uvicorn uvicorn main_1_nats:app --reload ``` ```bash uvicorn main_2_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` ```bash pip install gunicorn gunicorn main_3_mesop:app -b 0.0.0.0:8888 --reload ``` -------------------------------- ### Run env + pip Setup (Windows) Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi_nats/index.md Commands to initialize the NATS container and start the application services on Windows, using waitress for the web interface. ```bash docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf ``` ```bash pip install uvicorn uvicorn main_1_nats:app --reload ``` ```bash uvicorn main_2_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` ```bash pip install waitress waitress-serve --listen=0.0.0.0:8888 main_3_mesop:app ``` -------------------------------- ### Run Custom REST API and WebSocket Setup Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi_nats/index.md Commands to start the NATS container and the custom FastAPI application components. ```bash docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf ``` ```bash uvicorn main_1_nats:app --reload ``` ```bash uvicorn main_2_fastapi_custom_client:app --port 8008 --reload ``` -------------------------------- ### Console Output for WhatsAppAgent Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/whatsapp.md Example console output showing the initialization and workflow start for the WhatsAppAgent. ```console ╭─── Python package file structure ────╮ │ │ │ 📁 docs │ │ ├── 🐍 __init__.py │ │ └── 📁 docs_src │ │ ├── 🐍 __init__.py │ │ └── 📁 user_guide │ │ ├── 🐍 __init__.py │ │ └── 📁 runtimes │ │ ├── 🐍 __init__.py │ │ └── 📁 autogen │ │ ├── 🐍 __init__.py │ │ └── 🐍 whatsapp.py │ │ │ ╰──────────────────────────────────────╯ 2024-11-06 12:05:31,205 [INFO] Importing autogen.base.py /home/vscode/.local/lib/python3.10/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2: * 'keep_untouched' has been renamed to 'ignored_types' warnings.warn(message, UserWarning) 2024-11-06 12:05:31,512 [INFO] Patched OpenAPIParser.parse_schema 2024-11-06 12:05:31,512 [INFO] Patched Operation.function_name 2024-11-06 12:05:31,512 [INFO] Patched fastapi_code_generator.__main__.generate_code 2024-11-06 12:05:31,512 [INFO] Patched Parser.__apply_discriminator_type, 2024-11-06 12:05:31,712 [INFO] Initializing FastAgency with workflows: and UI: 2024-11-06 12:05:31,712 [INFO] Initialized FastAgency: ╭───────────────────── Importable FastAgency app ──────────────────────╮ │ │ │ from docs.docs_src.user_guide.runtimes.ag2.whatsapp import app │ │ │ ╰──────────────────────────────────────────────────────────────────────╯ ╭─ Workflow -> User [workflow_started] ────────────────────────────────╮ │ │ │ { │ │ "name": "simple_whatsapp", │ │ "description": "WhatsApp chat", │ │ │ │ "params": {} │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮ │ │ │ I can help you with sending a message over whatsapp, what would you │ │ like to send?: │ ╰──────────────────────────────────────────────────────────────────────────────╯ ``` -------------------------------- ### Start Application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/whatsapp/index.md Boilerplate code to start the application. ```python {! docs/en/tutorials/mesop_template.md[ln:132-138] !} ``` -------------------------------- ### Install and Run with Gunicorn on Linux/MacOS Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Install Gunicorn via pip and start the application server. ```console pip install gunicorn gunicorn main:app ``` -------------------------------- ### Install Dependencies Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/prompt_leakage_probing/index.md Command to install the project and its development dependencies. ```bash pip install ."[dev]" ``` -------------------------------- ### Run Cookiecutter Mesop Setup Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi_nats/index.md Commands to start the FastAPI conversational workflow, NATS-integrated FastAPI, and Mesop interface in separate terminals. ```bash uvicorn main_1_nats:app --reload ``` ```bash uvicorn main_2_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` ```bash gunicorn main_3_mesop:app -b 0.0.0.0:8888 --reload ``` -------------------------------- ### Install OpenAPI Dependencies Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Install additional dependencies required for the tutorial. ```bash pip install "fastagency[openapi]" ``` -------------------------------- ### Complete Application Examples Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Full application code for different authentication scenarios. ```python {!> docs_src/user_guide/ui/mesop/main_mesop.py !} ``` ```python {!> docs_src/user_guide/ui/mesop/main_mesop_basic_auth.py !} ``` ```python {!> docs_src/user_guide/ui/mesop/main_mesop_firebase_auth.py !} ``` -------------------------------- ### Run the Application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/index.md Commands to start the application server on different operating systems. ```console gunicorn main:app ``` ```console pip install gunicorn gunicorn main:app ``` ```console pip install waitress waitress-serve --listen=0.0.0.0:8000 main:app ``` -------------------------------- ### Manual Installation Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Install FastAgency with required submodules using pip. ```bash pip install "fastagency[autogen,mesop,openapi]" ``` -------------------------------- ### Start Secured Adapter Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/security.md Command to launch the FastAPI application using Uvicorn. ```bash uvicorn secured_fastapi_adapter.main:app --host 0.0.0.0 --port 8008 ``` -------------------------------- ### Install FastAgency Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/interactions.md Install the package using pip with the autogen extra. ```console pip install "fastagency[autogen]" ``` -------------------------------- ### Complete application code Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/api/security.md Full source code for the security configuration example. ```python {! docs_src/user_guide/external_rest_apis/security.py !} ``` -------------------------------- ### Install FastAgency with Mesop support Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Commands to install FastAgency with Mesop and optional authentication providers. ```bash pip install "fastagency[autogen,mesop]" ``` ```bash pip install "fastagency[autogen,mesop,basic_auth]" ``` ```bash pip install "fastagency[autogen,mesop,firebase]" ``` -------------------------------- ### Run NATS, FastAPI, and Mesop Applications Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Start the three required components for the NATS-integrated setup in separate terminal windows. ```bash uvicorn my_fastagency_app.deployment.main_1_nats:app --reload ``` ```bash uvicorn my_fastagency_app.deployment.main_2_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` ```bash gunicorn my_fastagency_app.deployment.main_3_mesop:app -b 0.0.0.0:8888 --reload ``` -------------------------------- ### Gunicorn Output Log Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Example output from the Gunicorn server startup. ```console [2024-10-10 13:19:18 +0530] [23635] [INFO] Starting gunicorn 23.0.0 [2024-10-10 13:19:18 +0530] [23635] [INFO] Listening at: http://127.0.0.1:8888 (23635) [2024-10-10 13:19:18 +0530] [23635] [INFO] Using worker: sync [2024-10-10 13:19:18 +0530] [23645] [INFO] Booting worker with pid: 23645 ``` -------------------------------- ### Azure subscription selection output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Example output showing the prompt for selecting an Azure subscription during deployment. ```console Retrieving tenants and subscriptions for the selection... [Tenant and subscription selection] No Subscription name Subscription ID Tenant ----- ------------------------------------ ------------------------------------ ------------------------ [1] * Subscription 1 18a56427-c3d6-4bd8-96fe-c99d96d5f1ef My Tenant Organization [2] Subscription 2 66699c06-f666-471f-b390-9d6af1f1b522 My Tenant Organization The default is marked with an *; the default tenant is 'My Tenant Organization' and subscription is 'Subscription 1' (18a56427-c3d6-4bd8-96fe-c99d96d5f1ef). ``` -------------------------------- ### Install Dependencies Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/security.md Installation commands for FastAgency with FastAPI support, including optional JWT and password hashing libraries. ```bash pip install "fastagency[autogen,mesop,fastapi,server]" ``` ```bash pip install "fastagency[autogen,mesop,fastapi,server]" PyJWT "passlib[bcrypt]" ``` -------------------------------- ### Run FastAPI Application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs_src/getting_started/basic_auth/fastapi/my_fastagency_app/README.md Starts the FastAPI server using uvicorn. ```bash uvicorn my_fastagency_app.deployment.main_1_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` -------------------------------- ### Configuring the Language Model Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/api/openapi/index.md Setup for the gpt-4o-mini model using an API key from the environment. ```python {! docs_src/user_guide/external_rest_apis/main.py [ln:10-14] !} ``` -------------------------------- ### Complete Application Code Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/interactions.md Full source code for the custom user interaction example. ```python {! docs_src/user_guide/custom_user_interactions/main.py!} ``` -------------------------------- ### Install FastAgency with Mesop support Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/index.md Installs FastAgency with AG2, Mesop, FastAPI, and server submodules. ```bash pip install "fastagency[autogen,mesop,fastapi,server]" ``` -------------------------------- ### Install Cookiecutter Source: https://github.com/ag2ai/fastagency/blob/main/README.md Install the Cookiecutter tool to facilitate project scaffolding. ```console pip install cookiecutter ``` -------------------------------- ### Main Application Entry Points Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/security.md Full implementation examples for simple OAuth2 and JWT-based authentication in main.py. ```python {!> docs_src/user_guide/adapters/fastapi/security/main_1_simple.py !} ``` ```python {!> docs_src/user_guide/adapters/fastapi/security/main_1_jwt.py !} ``` -------------------------------- ### Run Project Tests Source: https://github.com/ag2ai/fastagency/blob/main/README.md Execute the test suite to verify the project setup. ```console pytest -s ``` -------------------------------- ### Run FastAPI Application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Command to start the FastAPI application. ```bash uvicorn main_1_nats:app --reload ``` -------------------------------- ### Install FastAgency with OpenAPI support Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/api/openapi/index.md Install the necessary dependencies for using FastAgency with AG2 and OpenAPI functionality. ```console pip install "fastagency[autogen,openapi]" ``` -------------------------------- ### Install FastAgency for Custom REST API and Websocket Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/index.md Installs FastAgency with AG2, FastAPI, and server submodules for custom implementations. ```bash pip install "fastagency[autogen,fastapi,server]" ``` -------------------------------- ### Complete application source code Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/websurfer.md Full source code for the web surfing examples. ```python {!> docs_src/user_guide/runtimes/ag2/websurfer.py !} ``` ```python {!> docs_src/user_guide/runtimes/ag2/websurfer_tool.py !} ``` -------------------------------- ### Fly.io Registration Output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Example output confirming successful registration of an application name on Fly.io. ```console successfully logged in Registering app name in fly.io New app created: test-registration App name registered successfully Registered app name is: test-registration.fly.dev ``` -------------------------------- ### Fly.io Deployment Output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Example output showing the build and deployment process logs for a Fly.io application. ```console Checking if already logged into fly.io Already logged into fly.io Deploying to fly.io ==> Verifying app config Validating fly.toml ✓ Configuration is valid --> Verified app config ==> Building image ==> Building image with Depot --> build: (​) [+] Building 15.2s (13/13) FINISHED ... ... ... --> Build Summary: (​) --> Building image done image: registry.fly.io/write-fastagency-docs-delicate-waterfall-7272:deployment-01JCFQP31QFJWA9HVVYPZYH1QN image size: 498 MB Watch your deployment at https://fly.io/apps/write-fastagency-docs-delicate-waterfall-7272/monitoring Provisioning ips for write-fastagency-docs-delicate-waterfall-7272 Dedicated ipv6: 2a09:8280:1::4f:f553:0 Shared ipv4: 66.241.124.140 Add a dedicated ipv4 with: fly ips allocate-v4 This deployment will: * create 2 "app" machines No machines in group app, launching a new machine Creating a second machine to increase service availability Finished launching new machines ------- NOTE: The machines for [app] have services with 'auto_stop_machines = "stop"' that will be stopped when idling ------- Checking DNS configuration for write-fastagency-docs-delicate-waterfall-7272.fly.dev Visit your newly deployed app at https://write-fastagency-docs-delicate-waterfall-7272.fly.dev/ Setting secrets Updating existing machines in 'write-fastagency-docs-delicate-waterfall-7272' with rolling strategy ------- ✔ [1/2] Machine 48e2764ce93e58 [app] update succeeded ✔ [2/2] Machine e825942c739518 [app] update succeeded ------- Checking DNS configuration for write-fastagency-docs-delicate-waterfall-7272.fly.dev ``` -------------------------------- ### Run Mesop with Waitress on Windows Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Commands to install and run the Mesop interface with waitress on Windows. ```bash pip install waitress waitress-serve --listen=0.0.0.0:8888 main_2_mesop:app ``` -------------------------------- ### Application Output Logs Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/index.md Expected console output when starting the services. ```console [2024-10-10 13:19:18 +0530] [23635] [INFO] Starting gunicorn 23.0.0 [2024-10-10 13:19:18 +0530] [23635] [INFO] Listening at: http://127.0.0.1:8888 (23635) [2024-10-10 13:19:18 +0530] [23635] [INFO] Using worker: sync [2024-10-10 13:19:18 +0530] [23645] [INFO] Booting worker with pid: 23645 ``` ```console INFO: Will watch for changes in these directories: ['/tmp/custom_fastapi_demo'] INFO: Uvicorn running on http://0.0.0.0:8008 (Press CTRL+C to quit) INFO: Started reloader process [73937] using StatReload INFO: Started server process [73940] INFO: Waiting for application startup. INFO: Application startup complete. ``` -------------------------------- ### Run MesopUI Locally Source: https://github.com/ag2ai/fastagency/blob/main/README.md Commands to start the MesopUI server for testing workflows locally. ```console gunicorn my_fastagency_app.local.main_mesop:app ``` ```console waitress-serve --listen=0.0.0.0:8000 my_fastagency_app.local.main_mesop:app ``` -------------------------------- ### Run Mesop Web Interface Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Command to start the Mesop web interface using gunicorn. ```bash gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload ``` -------------------------------- ### Install FastAgency with NATS support Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Install the necessary dependencies including NATS support via pip. ```bash pip install "fastagency[autogen,mesop,fastapi,server,nats]" ``` -------------------------------- ### Run Mesop UI Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs_src/getting_started/basic_auth/nats_n_fastapi/my_fastagency_app/README.md Starts the Mesop UI server on port 8888 using gunicorn. ```bash gunicorn my_fastagency_app.deployment.main_3_mesop:app -b 0.0.0.0:8888 --reload ``` -------------------------------- ### Run FastAPI with Pip Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Commands to install and run the FastAPI application. ```bash pip install uvicorn uvicorn main_1_nats:app --reload ``` -------------------------------- ### Run with an initial message Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/cli/index.md Provides a custom starting message to the workflow for testing different conversation scenarios. ```bash fastagency run path/to/app.py --initial_message "Hello, let's start!" ``` -------------------------------- ### Run Mesop with Gunicorn Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Commands to install and run the Mesop interface with gunicorn. ```bash pip install gunicorn gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload ``` -------------------------------- ### Complete Application Source Code Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/whatsapp.md Full source code for the WhatsApp integration examples. ```python {!> docs_src/user_guide/runtimes/ag2/whatsapp.py !} ``` ```python {!> docs_src/user_guide/runtimes/ag2/whatsapp_tool.py !} ``` -------------------------------- ### Run Application with Gunicorn or Waitress Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Commands to start the application server on different operating systems. ```console gunicorn my_fastagency_app.deployment.main:app ``` ```console pip install gunicorn gunicorn deployment.main:app ``` ```console pip install waitress waitress-serve --listen=0.0.0.0:8000 deployment.main:app ``` -------------------------------- ### Workflow Configuration JSON Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/whatsapp.md Example of the workflow structure used for WhatsApp chat initialization. ```json { "name": "simple_whatsapp", "description": "WhatsApp chat", "params": {} } ``` -------------------------------- ### View deployment output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Example of the console output generated during a successful manual deployment to AWS. ```console Checking if AWS CLI is configured AWS CLI is configured. Ensuring role is correctly attached to instance profile ✅ Instance profile successfully configured Logging into Amazon ECR ... Login Succeeded Building Docker image [+] Building 2.0s (13/13) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.42kB 0.0s => [internal] load metadata for docker.io/library/python:3.12 1.9s => [internal] load .dockerignore 0.0s => => transferring context: 34B 0.0s => [1/8] FROM docker.io/library/python:3.12@sha256:752ce4a954589eb94d32849db7ede17ce120945cb71f6feabab3697550932ff9 0.0s ... => CACHED [8/8] RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app && chown -R appuser:appuser /etc/nginx/conf.d /var/log/nginx /var/li 0.0s => exporting to image 0.0s ... => => naming to docker.io/library/aws-fastagency-deploy:latest 0.0s Tagging and pushing Docker image to ECR The push refers to repository [617504802562.dkr.ecr.eu-central-1.amazonaws.com/aws-fastagency-deploy] ... latest: digest: sha256:6a24263dba170b67e2adf7dd029c188b0d894bcd9001125264173b8371e74764 size: 3259 617504802562.dkr.ecr.eu-central-1.amazonaws.com/aws-fastagency-deploy Creating/Updating Elastic Beanstalk Application ... Creating Dockerrun.aws.json Packaging Dockerrun.aws.json into app-deployment.zip ... Uploading app-deployment.zip to S3 bucket aws-fastagency-deploy ... Creating new application version: v20241213093740 Creating/Updating Elastic Beanstalk Environment ... Waiting for environment to be ready Setting environment variables Waiting for environment to be ready Your AWS Elastic Beanstalk application is deployed at: http://aws-fastagency-deploy-env.eba-ej2gjxf3.eu-central-1.elasticbeanstalk.com ``` -------------------------------- ### Cookiecutter Configuration Options Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Example of the interactive prompts provided by the Cookiecutter template. ```console [1/4] project_name (My FastAgency App): [2/4] project_slug (my_fastagency_app): [3/4] Select app_type 1 - fastapi+mesop 2 - mesop 3 - nats+fastapi+mesop Choose from [1/2/3] (1): 2 [4/4] Select python_version 1 - 3.12 2 - 3.11 3 - 3.10 Choose from [1/2/3] (1): ``` -------------------------------- ### Start NATS Docker Container Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Command to launch the NATS container for the application. ```bash docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf ``` -------------------------------- ### Cookiecutter Prompt Output Source: https://github.com/ag2ai/fastagency/blob/main/README.md Example of the interactive prompts displayed during project generation. ```console [1/4] project_name (My FastAgency App): [2/4] project_slug (my_fastagency_app): [3/4] Select app_type 1 - fastapi+mesop 2 - mesop 3 - nats+fastapi+mesop Choose from [1/2/3] (1): 1 [4/4] Select python_version 1 - 3.12 2 - 3.11 3 - 3.10 Choose from [1/2/3] (1): [5/5] Select authentication 1 - none 2 - google Choose from [1/2] (1): ``` -------------------------------- ### Fly.io Login Output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Example output showing the authentication process when logging into Fly.io via the CLI. ```console Checking if already logged into fly.io Logging into fly.io failed opening browser. Copy the url (https://fly.io/app/auth/cli/78366a6d347a377a6e346465776167726f6b693537666a333674346978626d37) into a browser and continue Opening https://fly.io/app/auth/cli/78366a6d347a377a6e346465776167726f6b693537666a333674346978626d37 ... Waiting for session... ``` -------------------------------- ### Run Custom REST API Application Command Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/index.md Command to start the custom FastAPI application. ```bash uvicorn main_fastapi_custom_client:app --port 8008 --reload ``` -------------------------------- ### Console Output for WhatsApp Tool Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/whatsapp.md Example console output showing the file structure for the WhatsApp tool enhancement. ```console ╭────── Python package file structure ──────╮ │ │ │ 📁 docs │ │ ├── 🐍 __init__.py │ │ └── 📁 docs_src │ │ ├── 🐍 __init__.py │ │ └── 📁 user_guide │ │ ├── 🐍 __init__.py │ │ └── 📁 runtimes │ │ ├── 🐍 __init__.py │ │ └── 📁 autogen │ │ ├── 🐍 __init__.py │ │ └── 🐍 whatsapp_tool.py │ │ │ ╰───────────────────────────────────────────╯ ``` -------------------------------- ### Run NATS Adapter Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs_src/getting_started/basic_auth/nats_n_fastapi/my_fastagency_app/README.md Starts the NATS adapter using uvicorn to handle workflow conversation messages. ```bash uvicorn my_fastagency_app.deployment.main_1_nats:app --reload ``` -------------------------------- ### Create and Run Application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/index.md Launches the FastAgency application using the Mesop interface. ```python {! docs_src/user_guide/runtimes/ag2/mesop/main.py [ln:79] !} ``` -------------------------------- ### Initialize FastAgency Project Source: https://github.com/ag2ai/fastagency/blob/main/README.md Run the Cookiecutter template to generate the project structure. ```console cookiecutter https://github.com/ag2ai/cookiecutter-fastagency.git ``` -------------------------------- ### Initialize and push to GitHub Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Commands to initialize a local git repository and push the project to a remote GitHub repository. ```console git init git add . git commit -m "Initial commit" git remote add origin https://github.com//.git git branch -M main git push -u origin main ``` -------------------------------- ### Configure Language Model Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/console/basics.md Set up the LLM configuration using gpt-4o-mini with a deterministic temperature setting. ```python {! docs_src/getting_started/no_auth/mesop/my_fastagency_app/my_fastagency_app/workflow.py [ln:8-17] !} ``` -------------------------------- ### Install FastAgency with Custom REST and NATS support Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi_nats/index.md Installs FastAgency with AG2, FastAPI, server, and NATS dependencies for custom API implementations. ```bash pip install "fastagency[autogen,fastapi,server,nats]" ``` -------------------------------- ### Launching the application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/websurfer.md Create and run the FastAgency application via the console interface. ```python {! docs_src/user_guide/runtimes/ag2/websurfer.py [ln:53] !} ``` -------------------------------- ### Configure NatsAdapter Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Initialize the NatsAdapter with the defined workflow. ```python {!> docs_src/getting_started/no_auth/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:9-13] !} ``` -------------------------------- ### Initiate Chat Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/giphy/index.md Starts the conversation between agents and summarizes the interaction upon completion. ```python chat_result = user_proxy.initiate_chat( giphy_agent, message=user_input, max_turns=10, summary_method=reflection_with_llm, ) return chat_result.summary ``` -------------------------------- ### Initiate WhatsApp Conversation Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/whatsapp.md Starts the chat interaction and triggers the message sending process. ```python {! docs_src/user_guide/runtimes/ag2/whatsapp.py [ln:50-57] !} ``` ```python {! docs_src/user_guide/runtimes/ag2/whatsapp_tool.py [ln:55-62] !} ``` -------------------------------- ### Complete Application Files Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/console/basics.md Full source code for the workflow and main entry point. ```python {! docs_src/getting_started/no_auth/mesop/my_fastagency_app/my_fastagency_app/workflow.py !} ``` ```python {! docs_src/getting_started/no_auth/mesop/my_fastagency_app/my_fastagency_app/local/main_console.py !} ``` -------------------------------- ### Build and Run Docker Image Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs_src/getting_started/basic_auth/fastapi/my_fastagency_app/README.md Commands to build the Docker image and run it as a container. ```bash docker build -t deploy_fastagency -f docker/Dockerfile . ``` ```bash docker run --rm -d --name deploy_fastagency -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8008:8008 -p 8888:8888 deploy_fastagency ``` -------------------------------- ### Configure the Language Model Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Set up the LLM configuration, including the model name and API key, with temperature set to 0.0 for deterministic behavior. ```python {! docs_src/user_guide/ui/mesop/main_mesop.py [ln:16-20] !} ``` -------------------------------- ### FastAgency Console Execution Output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/console/basics.md Displays the console output during the initialization and start of a FastAgency workflow. ```console ╭─ Python module file ─╮ │ │ │ 🐍 main.py │ │ │ ╰──────────────────────╯ ╭─ Importable FastAgency app ─╮ │ │ │ from main import app │ │ │ ╰─────────────────────────────╯ ╭─ Workflow -> User [workflow_started] ────────────────────────────────╮ │ │ │ { │ │ "name": "simple_learning", │ │ "description": "Student and teacher │ │ learning chat", │ │ "params": {} │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮ │ │ │ I can help you learn about mathematics. What subject you would like to │ │ explore?: │ ╰──────────────────────────────────────────────────────────────────────────────╯ ``` -------------------------------- ### fastagency.ui.mesop.main.create_home_page Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/api/fastagency/ui/mesop/main/create_home_page.md Initializes and creates the home page component for the Mesop-based UI in FastAgency. ```APIDOC ## fastagency.ui.mesop.main.create_home_page ### Description This function is used to generate the home page layout and functionality for the Mesop UI implementation within FastAgency. ### Signature `fastagency.ui.mesop.main.create_home_page()` ``` -------------------------------- ### Initiating agent interaction Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/websurfer.md Start the conversation between agents to perform web searches and summarize results. ```python {! docs_src/user_guide/runtimes/ag2/websurfer.py [ln:42-50] !} ``` ```python {! docs_src/user_guide/runtimes/ag2/websurfer_tool.py [ln:53-61] !} ``` -------------------------------- ### Configuring the Language Model Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/whatsapp.md Sets up the LLM configuration using gpt-4o and environment-based API keys for agent interaction. ```python {! docs_src/user_guide/runtimes/ag2/whatsapp.py [ln:11-15] !} ``` -------------------------------- ### Implement Mesop Client App Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi_nats/index.md Sets up the Mesop UI client to communicate with the FastAPI provider. ```python {!> docs_src/getting_started/no_auth/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_3_mesop.py [ln:1-15] !} ``` -------------------------------- ### Run Mesop Application Commands Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/index.md Commands to start FastAPI and Mesop services in separate terminals. ```bash uvicorn main_1_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` ```bash gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload ``` ```bash pip install uvicorn uvicorn main_1_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` ```bash pip install gunicorn gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload ``` ```bash pip install waitress waitress-serve --listen=0.0.0.0:8888 main_2_mesop:app ``` -------------------------------- ### Define Deployment Main Entry Point Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md The main entry point for the application deployment using MesopUI. ```python {! docs_src/getting_started/no_auth/mesop/my_fastagency_app/my_fastagency_app/deployment/main.py [ln:1-10] !} ``` -------------------------------- ### Run FastAPI Service Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/prompt_leakage_probing/index.md Execute the local script to start the FastAPI service for the probing framework. ```bash source ./scripts/run_fastapi_locally.sh ``` -------------------------------- ### Configuring the LLM Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/api/dependency_injection/index.md Set up the LLM configuration using the gpt-4o-mini model and environment-based API keys. ```python {! docs_src/user_guide/dependency_injection/workflow.py [ln:25-29] !} ``` -------------------------------- ### Initiate Chat Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/whatsapp/index.md Starts the conversation between agents and the user with a defined turn limit and reflection summary. ```python {! docs_src/tutorials/whatsapp/main.py [ln:114-122] !} ``` -------------------------------- ### Initialize FastAgency Application Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Initializes the FastAgency app with registered workflows and the MesopUI interface. ```python {! docs_src/getting_started/no_auth/mesop/my_fastagency_app/my_fastagency_app/deployment/main.py [ln:6-10] !} ``` -------------------------------- ### WebSurfer console output examples Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/websurfer.md Expected console logs when running WebSurfer-based FastAgency applications. ```console ╭── Python module file ───╮ │ │ │ 🐍 websurfer_agent.py │ │ │ ╰─────────────────────────╯ [INFO] Importing autogen.base.py [INFO] Initializing FastAgency with workflows: and UI: [INFO] Initialized FastAgency: ╭──── Importable FastAgency app ────╮ │ │ │ from websurfer_agent import app │ │ │ ╰───────────────────────────────────╯ ╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮ │ │ │ { │ │ "name": "simple_websurfer", │ │ "description": "WebSurfer chat", │ │ │ │ "params": {} │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮ │ │ │ I can help you with your web search. What would you like to know?: │ ╰──────────────────────────────────────────────────────────────────────────────╯ ``` ```console ╭── Python module file ──╮ │ │ │ 🐍 websurfer_tool.py │ │ │ ╰────────────────────────╯ [INFO] Importing autogen.base.py [INFO] Initializing FastAgency with workflows: and UI: [INFO] Initialized FastAgency: ╭─── Importable FastAgency app ────╮ │ │ │ from websurfer_tool import app │ │ │ ╰──────────────────────────────────╯ ╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮ │ │ │ { │ │ "name": "simple_websurfer", │ │ "description": "WebSurfer chat", │ │ │ │ "params": {} │ │ } │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮ │ │ │ I can help you with your web search. What would you like to know?: │ ╰──────────────────────────────────────────────────────────────────────────────╯ ``` -------------------------------- ### Instantiate MesopUI Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Link the workflow to a web-based interface using MesopUI, with support for optional authentication. ```python {!> docs_src/user_guide/ui/mesop/main_mesop.py [ln:55-84] !} ``` ```python {!> docs_src/user_guide/ui/mesop/main_mesop_basic_auth.py [ln:56-96] !} ``` -------------------------------- ### Defining agents and workflows Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/runtimes/ag2/websurfer.md Initialize agents and define the workflow structure for web surfing tasks. ```python {!> docs_src/user_guide/runtimes/ag2/websurfer.py [ln:17-41] !} ``` ```python {!> docs_src/user_guide/runtimes/ag2/websurfer_tool.py [ln:17-47] !} ``` ```python {!> docs_src/user_guide/runtimes/ag2/websurfer_tool.py [ln:49-52] !} ``` -------------------------------- ### Open Project in VS Code Source: https://github.com/ag2ai/fastagency/blob/main/README.md Launch the generated project directory in Visual Studio Code. ```console code my_fastagency_app ``` -------------------------------- ### Initialize WhatsApp API Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/whatsapp/index.md Loads the OpenAPI specification and configures security parameters using the API key. ```python {! docs_src/tutorials/whatsapp/main.py [ln:20-28] !} ``` -------------------------------- ### Run FastAPI Adapter Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs_src/getting_started/basic_auth/nats_n_fastapi/my_fastagency_app/README.md Starts the FastAPI adapter on port 8008 to handle NATS messages via NatsProvider. ```bash uvicorn my_fastagency_app.deployment.main_2_fastapi:app --host 0.0.0.0 --port 8008 --reload ``` -------------------------------- ### GET /items/ Source: https://github.com/ag2ai/fastagency/blob/main/tests/api/openapi/security/expected_main_gen.txt Retrieves items based on the provided city parameter. Requires an access_token via header or cookie. ```APIDOC ## GET /items/ ### Description Read items for a specified city. This endpoint requires authentication using an 'access_token' provided either in the request header or as a cookie. ### Method GET ### Endpoint /items/ ### Parameters #### Query Parameters - **city** (string) - Required - city for which forecast is requested ### Response #### Success Response (200) - **data** (Any) - The requested item data. #### Error Response (422) - **detail** (array) - Validation error details. ``` -------------------------------- ### Authenticate and Get OAuth2 Token Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/security.md Obtain an access token by sending user credentials to the FastAPI authentication endpoint. ```python {!> docs_src/user_guide/adapters/fastapi/security/simple_client.py [ln:16-27]!} ``` -------------------------------- ### Import Required Modules Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/nats/index.md Import necessary FastAgency components and the NatsAdapter. ```python {!> docs_src/getting_started/no_auth/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:1-7] !} ``` -------------------------------- ### Set API Keys in Environment Variables Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/whatsapp/index.md Configure the required API keys for WhatsApp and Bing services in your local environment. ```bash export WHATSAPP_API_KEY="your_whatsapp_api_key" export BING_API_KEY="your_bing_api_key" ``` ```bash set WHATSAPP_API_KEY="your_whatsapp_api_key" set BING_API_KEY="your_bing_api_key" ``` -------------------------------- ### FastAPI App Initialization Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/security.md Defining the FastAPI application instance. ```python {!> docs_src/user_guide/adapters/fastapi/security/main_1_simple.py [ln:11]!} ``` ```python {!> docs_src/user_guide/adapters/fastapi/security/main_1_jwt.py [ln:15]!} ``` -------------------------------- ### View Project Structure Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/mesop_template.md Displays the generated file structure for the project. ```console {!> docs_src/getting_started/no_auth/mesop/folder_structure.txt !} ``` -------------------------------- ### Run FastAgency in development mode Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/cli/index.md Executes the app with live reload enabled for real-time updates. ```bash fastagency dev path/to/app.py ``` -------------------------------- ### Open Project in VSCode Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs_src/getting_started/basic_auth/fastapi/my_fastagency_app/README.md Opens the current directory in VSCode. ```bash code . ``` -------------------------------- ### Workflow Initialization Output Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/api/security.md Displays the initial workflow configuration parameters. ```json { "name": "simple_weather_with_security", "description": "Weather chat with security", "params": {} } ``` -------------------------------- ### Run MesopUI Locally Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Imports the workflow and initializes the MesopUI interface for local debugging. ```python {! docs_src/getting_started/basic_auth/mesop/my_fastagency_app/my_fastagency_app/local/main_mesop.py !} ``` -------------------------------- ### Run Mesop with Gunicorn Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/ui/mesop/basics.md Execute the application using Gunicorn for production environments. ```console gunicorn main:app ``` -------------------------------- ### Clone the Repository Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/tutorials/prompt_leakage_probing/index.md Commands to download the framework source code from the remote repository. ```bash git clone https://github.com/airtai/prompt-leakage-probing.git cd prompt-leakage-probing ``` -------------------------------- ### Configure the Language Model Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/api/security.md Initialize the LLM using environment variables for the API key. ```python {! docs_src/user_guide/external_rest_apis/security.py [ln:11-15] !} ``` -------------------------------- ### Adapter Chaining and Serving Client Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/adapters/fastapi/index.md Configures the UI layer or serves the custom HTML client for the application. ```python {!> docs_src/getting_started/no_auth/fastapi/my_fastagency_app/my_fastagency_app/deployment/main_2_mesop.py [ln:1-15] !} ``` ```python {!> docs_src/getting_started/no_auth/fastapi/main_fastapi_custom_client.py [ln:12-98,146-148] !} ``` -------------------------------- ### Execute AWS deployment script Source: https://github.com/ag2ai/fastagency/blob/main/docs/docs/en/user-guide/getting-started/index.md Run the provided shell script to initiate the manual deployment process to AWS. ```console ./scripts/deploy_to_aws.sh ```