Skip to content

Commit

Permalink
Merge pull request #32 from crestalnetwork/chore/release-script
Browse files Browse the repository at this point in the history
Chore: release script
  • Loading branch information
taiyangc authored Jan 7, 2025
2 parents 2f05b88 + 3da6a10 commit 62359ca
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 35 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Docker Image
name: Build Docker Image and Deploy

on:
push:
Expand All @@ -9,6 +9,8 @@ on:
- '.github/**'
- 'docs/**'
- '*.md'
release:
types: [ prereleased, released ]

jobs:
docker:
Expand Down Expand Up @@ -81,6 +83,33 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Configure AWS Credentials
if: ${{ github.event_name == 'release' }}
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.AWS_ID }}:role/GithubActions

- name: Deploy to Amazon EKS Dev
if: ${{ github.event_name == 'release' && github.event.action == 'prereleased' }}
run: |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.EKS_DEV_CLUSTER }}
kubectl version
kubectl set image -n testnet-dev deployment/intent-api intent-api=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-dev deployment/intent-autonomous intent-autonomous=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-dev deployment/intent-twitter intent-twitter=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-dev deployment/intent-tg intent-tg=crestal/intentkit:${{ github.event.release.tag_name }}
- name: Deploy to Amazon EKS Prod
if: ${{ github.event_name == 'release' && github.event.action == 'released' }}
run: |
aws eks update-kubeconfig --region ${{ secrets.AWS_REGION }} --name ${{ secrets.EKS_PROD_CLUSTER }}
kubectl version
kubectl set image -n testnet-prod deployment/intent-api intent-api=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-prod deployment/intent-autonomous intent-autonomous=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-prod deployment/intent-twitter intent-twitter=crestal/intentkit:${{ github.event.release.tag_name }}
kubectl set image -n testnet-prod deployment/intent-tg intent-tg=crestal/intentkit:${{ github.event.release.tag_name }}
- name: Build Success
if: ${{ success() }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 2025-01-06

### New Features
- Optional JWT Authentication for admin API

### Improvements
- Refactor the core ai agent engine for better architecture
- Telegram entrypoint greeting message

### Bug Fixes
- Fix bug that agent config update not taking effect sometimes

## 2025-01-05

### Improvements
- Telegram entrypoint support regenerate token
- Telegram entrypoint robust error handling

## 2025-01-03

### Improvements
- Telegram entrypoint support dynamic enable and disable
- Better conversation behavior about the wallet

## 2025-01-02

### New Features
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ ARG RELEASE
ENV RELEASE=$RELEASE

# Command to run the application using Poetry
CMD ["poetry", "run", "uvicorn", "app.entrypoints.api:app", "--host", "0.0.0.0", "--port", "80"]
CMD ["poetry", "run", "uvicorn", "app.api:app", "--host", "0.0.0.0", "--port", "80"]
9 changes: 0 additions & 9 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,10 @@
from app.core.api import core_router
from app.entrypoints.web import chat_router
from app.models.db import init_db
from utils.logging import JsonFormatter

# init logger
logger = logging.getLogger(__name__)

# Configure uvicorn access logger to use our JSON format in non-local env
if config.env != "local" and not config.debug:
uvicorn_access = logging.getLogger("uvicorn.access")
uvicorn_access.handlers = [] # Remove default handlers
handler = logging.StreamHandler()
handler.setFormatter(JsonFormatter())
uvicorn_access.addHandler(handler)


@asynccontextmanager
async def lifespan(app: FastAPI):
Expand Down
39 changes: 37 additions & 2 deletions app/models/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sqlalchemy.dialects.postgresql import ARRAY, JSONB
from sqlmodel import Field, Session, SQLModel, select

from app.config.config import config
from utils.slack_alert import send_slack_message


Expand Down Expand Up @@ -83,9 +84,43 @@ def create_or_update(self, db: Session) -> None:
total_agents = db.exec(select(func.count()).select_from(Agent)).one()
# Send a message to Slack
send_slack_message(
f"New agent created: {self.id}",
"New agent created",
attachments=[
{"text": f"Total agents: {total_agents}", "color": "good"}
{
"color": "good",
"fields": [
{"title": "ENV", "short": True, "value": config.env},
{"title": "Total", "short": True, "value": total_agents},
{"title": "ID", "short": True, "value": self.id},
{"title": "Name", "short": True, "value": self.name},
{"title": "Model", "short": True, "value": self.model},
{
"title": "Autonomous",
"short": True,
"value": str(self.autonomous_enabled),
},
{
"title": "Twitter",
"short": True,
"value": str(self.twitter_enabled),
},
{
"title": "Telegram",
"short": True,
"value": str(self.telegram_enabled),
},
{
"title": "CDP Enabled",
"short": True,
"value": str(self.cdp_enabled),
},
{
"title": "CDP Network",
"short": True,
"value": self.cdp_network_id or "Default",
},
],
}
],
)
db.commit()
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ services:
- CDP_API_KEY_NAME=${CDP_API_KEY_NAME}
- CDP_API_KEY_PRIVATE_KEY=${CDP_API_KEY_PRIVATE_KEY}
- INTERNAL_BASE_URL=http://api:8000
command: poetry run python -m app.entrypoints.telegram
command: poetry run python -m app.telegram

volumes:
postgres_data:
32 changes: 16 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fastapi = "^0.115.6"
uvicorn = "^0.34.0"
gunicorn = "^23.0.0"
pydantic = "*"
pydantic-settings = "^2.7.0"
pydantic-settings = "^2.7.1"
sqlmodel = "^0.0.22"
sqlalchemy = "^2.0.36"
psycopg = "^3.2.3"
Expand All @@ -25,10 +25,10 @@ langchain-core = "^0.3.28"
langchain-openai = "^0.2.11"
langchain-postgres = "^0.0.12"
langchain-community = "^0.3.13"
langgraph = "^0.2.56"
langgraph = "^0.2.61"
langgraph-checkpoint = "^2.0.8"
langgraph-checkpoint-postgres = "^2.0.8"
openai = "^1.57.0"
openai = "^1.59.3"
cdp-langchain = "^0.0.8"
cdp-sdk = "^0.12.0"
cdp-agentkit-core = "^0.0.6"
Expand All @@ -39,8 +39,8 @@ anyio = "^4.7.0"
slack-sdk = "^3.34.0"
requests = "^2.32.3"
aws-secretsmanager-caching = "^1.1.3"
botocore = "^1.35.90"
aiogram = "^3.16.0"
botocore = "^1.35.93"
aiogram = "^3.17.0"

[tool.poetry.group.dev]
optional = true
Expand Down
10 changes: 10 additions & 0 deletions utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def setup_logging(env: str, debug: bool = False):
env: Environment name ('local', 'prod', etc.)
debug: Debug mode flag
"""

if env == "local" or debug:
# Set up logging configuration for local/debug
logging.basicConfig(
Expand All @@ -52,3 +53,12 @@ def setup_logging(env: str, debug: bool = False):
handler.setFormatter(JsonFormatter())
logging.basicConfig(level=logging.INFO, handlers=[handler])
logging.getLogger("sqlalchemy.engine").setLevel(logging.WARNING)
# fastapi access log
uvicorn_access = logging.getLogger("uvicorn.access")
uvicorn_access.handlers = [] # Remove default handlers
handler = logging.StreamHandler()
handler.setFormatter(JsonFormatter())
uvicorn_access.addHandler(handler)
uvicorn_access.setLevel(logging.WARNING)
# telegram access log
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)

0 comments on commit 62359ca

Please sign in to comment.