Skip to main content

Integration

System Service Integration

Ubuntu SystemD Service

Create a service file for AutoGen applications:

bash


# Create service file
sudo vim /etc/systemd/system/autogen.service

ini


[Unit]
Description=AutoGen Multi-Agent Service
After=network.target
Wants=network.target
[Service]
Type=simple
User=autogen
Group=autogen
WorkingDirectory=/opt/autogen
Environment=PATH=/opt/autogen/autogen-env/bin
ExecStart=/opt/autogen/autogen-env/bin/python /opt/autogen/main.py
Restart=always
RestartSec=10
EnvironmentFile=/etc/autogen/config.env
# Security settings
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/tmp/autogen_code
[Install]
WantedBy=multi-user.target

RHEL8 SystemD Service

bash


# Create service file
sudo vim /etc/systemd/system/autogen.service

The service file content is similar to Ubuntu, but with additional SELinux considerations:

ini


[Unit]
Description=AutoGen Multi-Agent Service
After=network.target
Wants=network.target
[Service]
Type=simple
User=autogen
Group=autogen
WorkingDirectory=/opt/autogen
Environment=PATH=/opt/autogen/autogen-env/bin
ExecStart=/opt/autogen/autogen-env/bin/python /opt/autogen/main.py
Restart=always
RestartSec=10
EnvironmentFile=/etc/autogen/config.env
SELinuxContext=system_u:system_r:unconfined_service_t:s0
[Install]
WantedBy=multi-user.target

Web Framework Integration

Flask Integration Example

python


# /opt/autogen/flask_app.py
from flask import Flask, request, jsonify
import autogen
import os
from llm_config import llm_config
app = Flask(__name__)
# Initialize agents
assistant = autogen.AssistantAgent(
name="assistant",
llm_config=llm_config,
system_message="You are a helpful AI assistant."
)
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER",
code_execution_config={
"work_dir": "/tmp/autogen_code",
"use_docker": False
}
)
@app.route('/chat', methods=['POST'])
def chat():
try:
message = request.json.get('message')
user_proxy.initiate_chat(assistant, message=message)
return jsonify({"status": "success", "response": "Chat completed"})
except Exception as e:
return jsonify({"status": "error", "message": str(e)}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)

atabase Integration

PostgreSQL Integration (Ubuntu)

bash


# Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib python3-psycopg2
# Install Python PostgreSQL adapter
pip install psycopg2-binary SQLAlchemy

PostgreSQL Integration (RHEL8)

bash



# Install PostgreSQL
sudo dnf install -y postgresql postgresql-server postgresql-contrib python3-psycopg2
# Initialize database
sudo postgresql-setup --initdb
sudo systemctl enable postgresql
sudo systemctl start postgresql
# Install Python adapter
pip install psycopg2-binary SQLAlchemy

API Gateway Integration

AutoGen can be integrated with API gateways like Nginx:

Ubuntu Nginx Setup

bash



# Install Nginx
sudo apt install -y nginx
# Create configuration
sudo vim /etc/nginx/sites-available/autogen

RHEL8 Nginx Setup

bash


# Install Nginx
sudo dnf install -y nginx
# Create configuration
sudo vim /etc/nginx/conf.d/autogen.conf

Nginx configuration for both systems:

nginx


server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}