Skip to content

Commit

Permalink
Alembic updates for custom agent migration + Readme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirenmathur committed Feb 19, 2025
1 parent 3cf9101 commit 664d4a7
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 18 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,22 @@ You can access Potpie Agents through an API key, enabling integration into CI/CD

Potpie is designed to be flexible and customizable. Here are key areas to personalize your own deployment:

### 1. System Prompts Configuration
Modify prompts in `app/modules/intelligence/prompts/system_prompt_setup.py`

### 2. Add New Agents
Create new agents in `app/modules/intelligence/agents/chat_agents` and `app/modules/intelligence/agents/agentic_tools`

### 3. Agent Behavior Customization
Modify guidelines within each agent's prompt in the `app/modules/intelligence/agents` directory
### 4. Tool Integration
Edit or add tools in the `app/modules/intelligence/tools` directory
### **Effortless Agent Creation**:
Design custom agents tailored to your specific tasks using a single prompt. Utilize the following API to create your custom agents:

```bash
curl -X POST "http://localhost:8001/api/v1/custom-agents/agents/auto" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Create an agent that assists users with scheduling appointments and sending reminders."
}'
```

Read more about other custom agent APIs to edit and delete your custom agents in our [documentation](https://docs.potpie.ai/open-source/agents/create-agent-from-prompt).

### Tool Integration
Edit or add tools in the `app/modules/intelligence/tools` directory for your custom agents.
Initialise the tools in the `app/modules/intelligence/tools/tool_service.py` file and include them in your agent.

## 🤝 Contributing

Expand Down
49 changes: 49 additions & 0 deletions app/alembic/versions/20241020111943_262d870e9686_custom_agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""custom_agents
Revision ID: 20241020111943_262d870e9686
Revises:
Create Date: 2024-10-20 11:19:43.653649
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '20241020111943_262d870e9686'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

# Add this line
branch_labels = ('custom_agents_microservice',)

def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('custom_agents',
sa.Column('id', sa.String(), nullable=False),
sa.Column('user_id', sa.String(), nullable=True),
sa.Column('role', sa.String(), nullable=True),
sa.Column('goal', sa.String(), nullable=True),
sa.Column('backstory', sa.String(), nullable=True),
sa.Column('system_prompt', sa.String(), nullable=True),
sa.Column('tasks', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('deployment_url', sa.String(), nullable=True),
sa.Column('deployment_status', sa.String(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_custom_agents_id'), 'custom_agents', ['id'], unique=False)
op.create_index(op.f('ix_custom_agents_user_id'), 'custom_agents', ['user_id'], unique=False)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_custom_agents_user_id'), table_name='custom_agents')
op.drop_index(op.f('ix_custom_agents_id'), table_name='custom_agents')
op.drop_table('custom_agents')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from app.modules.tasks.task_model import Task # noqa
from app.modules.users.user_model import User # noqa
from app.modules.users.user_preferences_model import UserPreferences # noqa
from app.modules.intelligence.agents.custom_agents.custom_agent_model import CustomAgent # noqa
2 changes: 1 addition & 1 deletion deployment/prod/celery/celery-api-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nodaemon=true
loglevel=debug

[program:celery]
command=/bin/bash -c 'source /app/.env && alembic upgrade head && echo "Starting Celery Worker with New Relic..." && newrelic-admin run-program celery -A app.celery.celery_app worker --loglevel=debug -Q "${CELERY_QUEUE_NAME}_process_repository" -E --concurrency=3 --max-memory-per-child=2000000 --max-tasks-per-child=200 --optimization=fair'
command=/bin/bash -c 'source /app/.env && alembic upgrade heads && echo "Starting Celery Worker with New Relic..." && newrelic-admin run-program celery -A app.celery.celery_app worker --loglevel=debug -Q "${CELERY_QUEUE_NAME}_process_repository" -E --concurrency=3 --max-memory-per-child=2000000 --max-tasks-per-child=200 --optimization=fair'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
Expand Down
2 changes: 1 addition & 1 deletion deployment/prod/convo-server/convo-api-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nodaemon=true
loglevel=debug

[program:gunicorn]
command=/bin/bash -c 'source /app/.env && alembic upgrade head && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
command=/bin/bash -c 'source /app/.env && alembic upgrade heads && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
Expand Down
2 changes: 1 addition & 1 deletion deployment/prod/mom-api/mom-api-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nodaemon=true
loglevel=debug

[program:gunicorn]
command=/bin/bash -c 'source /app/.env && alembic upgrade head && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
command=/bin/bash -c 'source /app/.env && alembic upgrade heads && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
Expand Down
2 changes: 1 addition & 1 deletion deployment/stage/celery/celery-api-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nodaemon=true
loglevel=debug

[program:celery]
command=/bin/bash -c 'source /app/.env && alembic upgrade head && echo "Starting Celery Worker with New Relic..." && newrelic-admin run-program celery -A app.celery.celery_app worker --loglevel=debug -Q "${CELERY_QUEUE_NAME}_process_repository" -E --concurrency=3'
command=/bin/bash -c 'source /app/.env && alembic upgrade heads && echo "Starting Celery Worker with New Relic..." && newrelic-admin run-program celery -A app.celery.celery_app worker --loglevel=debug -Q "${CELERY_QUEUE_NAME}_process_repository" -E --concurrency=3'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
Expand Down
2 changes: 1 addition & 1 deletion deployment/stage/convo-server/convo-api-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nodaemon=true
loglevel=debug

[program:gunicorn]
command=/bin/bash -c 'source /app/.env && alembic upgrade head && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
command=/bin/bash -c 'source /app/.env && alembic upgrade heads && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
Expand Down
2 changes: 1 addition & 1 deletion deployment/stage/mom-api/mom-api-supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nodaemon=true
loglevel=debug

[program:gunicorn]
command=/bin/bash -c 'source /app/.env && alembic upgrade head && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
command=/bin/bash -c 'source /app/.env && alembic upgrade heads && echo "Starting Gunicorn..." && newrelic-admin run-program gunicorn --workers $(nproc) --worker-class uvicorn.workers.UvicornWorker --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if ! pip install -r requirements.txt; then
fi

# Apply database migrations
alembic upgrade head
alembic upgrade heads

echo "Starting momentum application..."
gunicorn --worker-class uvicorn.workers.UvicornWorker --workers 1 --timeout 1800 --bind 0.0.0.0:8001 --log-level debug app.main:app &
Expand Down

0 comments on commit 664d4a7

Please sign in to comment.