Skip to content

Commit 1b85521

Browse files
Merge branch 'main' into jordan/one-off-jobs
2 parents 3ae53f7 + 2295623 commit 1b85521

File tree

151 files changed

+20225
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+20225
-65
lines changed

.github/workflows/build-samples-json.yml

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,96 @@
11
name: Trigger Docs Samples Rebuild
2+
permissions:
3+
contents: read
4+
pull-requests: read
25

36
on:
4-
push:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
59
branches:
6-
- main
10+
- "**"
711
paths:
812
- "samples/**"
913

1014
jobs:
15+
# python-lint:
16+
# runs-on: ubuntu-latest
17+
# steps:
18+
# - name: Checkout code
19+
# uses: actions/checkout@v4
20+
21+
# - name: Get list of changed files
22+
# id: changed
23+
# run: |
24+
# files=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep '\.py$' || true)
25+
# echo "files=$files" >> "$GITHUB_OUTPUT"
26+
27+
# - name: Run Ruff linter
28+
# uses: astral-sh/ruff-action@v1
29+
# with:
30+
# args: check
31+
# src: ${{ steps.changed.outputs.files }}
32+
33+
# - name: Run Ruff formatter check
34+
# uses: astral-sh/ruff-action@v1
35+
# with:
36+
# args: "format --check"
37+
# src: ${{ steps.changed.outputs.files }}
38+
39+
js-ts-lint:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version: "20"
49+
50+
- name: Get list of changed JS/TS files
51+
id: changed_js
52+
run: |
53+
files=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep -E '\.(js|ts|jsx|tsx)$' || true)
54+
echo "files=$files" >> "$GITHUB_OUTPUT"
55+
56+
- name: Run ESLint (JS/TS only)
57+
run: |
58+
if [ -n "${{ steps.changed_js.outputs.files }}" ]; then
59+
npx eslint ${{ steps.changed_js.outputs.files }}
60+
else
61+
echo "No JS/TS files to lint."
62+
fi
63+
64+
- name: Run Prettier check (JS/TS only)
65+
run: |
66+
if [ -n "${{ steps.changed_js.outputs.files }}" ]; then
67+
npx prettier --check ${{ steps.changed_js.outputs.files }}
68+
else
69+
echo "No JS/TS files to format check."
70+
fi
71+
72+
# go-lint:
73+
# runs-on: ubuntu-latest
74+
# steps:
75+
# - name: Checkout code
76+
# uses: actions/checkout@v4
77+
78+
# - name: Set up Golang
79+
# uses: actions/setup-go@v5
80+
# with:
81+
# go-version: stable
82+
83+
# - name: Run golangci-lint
84+
# uses: golangci/golangci-lint-action@v8
85+
# with:
86+
# args: --enable gofmt --enable goimports
87+
# only-new-issues: true
88+
# version: latest
89+
1190
build-json:
1291
runs-on: ubuntu-latest
92+
# needs: [python-lint, js-ts-lint, go-lint]
93+
needs: [js-ts-lint]
1394
steps:
1495
- name: Trigger CLI Autodoc
1596
uses: peter-evans/repository-dispatch@v1

.github/workflows/deploy-changed-samples.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy Changed Samples
33
on:
44
pull_request:
55
paths:
6-
- 'samples/**'
6+
- "samples/**"
77

88
permissions:
99
contents: read
@@ -82,6 +82,7 @@ jobs:
8282
TEST_MB_DB_PASS: ${{ secrets.TEST_MB_DB_PASS }}
8383
TEST_MB_DB_PORT: ${{ secrets.TEST_MB_DB_PORT }}
8484
TEST_MB_DB_USER: ${{ secrets.TEST_MB_DB_USER }}
85+
TEST_MISTRAL_API_KEY: ${{ secrets.TEST_MISTRAL_API_KEY }}
8586
TEST_MODEL: ${{ secrets.TEST_MODEL }}
8687
TEST_MONGO_INITDB_ROOT_USERNAME: ${{ secrets.TEST_MONGO_INITDB_ROOT_USERNAME }}
8788
TEST_MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.TEST_MONGO_INITDB_ROOT_PASSWORD }}
@@ -101,6 +102,7 @@ jobs:
101102
TEST_SLACK_CHANNEL_ID: ${{ secrets.TEST_SLACK_CHANNEL_ID }}
102103
TEST_SLACK_TOKEN: ${{ secrets.TEST_SLACK_TOKEN }}
103104
TEST_SHARED_SECRETS: ${{ secrets.TEST_SHARED_SECRETS}}
105+
TEST_TAVILY_API_KEY: ${{ secrets.TEST_TAVILY_API_KEY }}
104106
TEST_ALLOWED_HOSTS: ${{ secrets.TEST_ALLOWED_HOSTS }}
105107
run: |
106108
SAMPLES=$(sed 's|^samples/||' changed_samples.txt | paste -s -d ',' -)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Defang Software Labs
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
FROM mcr.microsoft.com/devcontainers/python:3.13-bookworm
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"context": ".."
5+
},
6+
"features": {
7+
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
9+
"ghcr.io/devcontainers/features/aws-cli:1": {}
10+
}
11+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
environment: playground
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
steps:
17+
- name: Checkout Repo
18+
uses: actions/checkout@v4
19+
20+
- name: Deploy
21+
uses: DefangLabs/[email protected]
22+
with:
23+
config-env-vars: MISTRAL_API_KEY
24+
env:
25+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}

samples/agentic-autogen/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Environment variables
2+
.env
3+
.env.local
4+
.env.production
5+
6+
# Python
7+
__pycache__/
8+
/myenv
9+
10+
# Node.js
11+
node_modules/
12+
npm-debug.log*
13+
.pnpm-debug.log*
14+
15+
# Frontend build
16+
frontend/dist/
17+
frontend/build/
18+
19+
# IDE
20+
.vscode/
21+
.idea/
22+
*~
23+
24+
# OS
25+
.DS_Store
26+
._*
27+
Thumbs.db
28+
29+
# Optional npm cache directory
30+
.npm

samples/agentic-autogen/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Agentic Autogen
2+
3+
[![1-click-deploy](https://raw.githubusercontent.com/DefangLabs/defang-assets/main/Logos/Buttons/SVG/deploy-with-defang.svg)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-agentic-autogen-template%26template_owner%3DDefangSamples)
4+
5+
This sample shows an agentic Autogen application using Mistral and FastAPI, deployed with Defang. For demonstration purposes, it will require a [Mistral AI](https://mistral.ai/) API key (see [Configuration](#configuration) for more details). However, you are free to modify it to use a different LLM, say the [Defang OpenAI Access Gateway](https://github.com/DefangLabs/openai-access-gateway/) service, as an alternative. Note that the Vite React frontend is served through the FastAPI backend so that they can be treated as one service in production.
6+
7+
## Prerequisites
8+
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
12+
13+
## Development
14+
15+
To run the application locally, you can use the following command:
16+
17+
```bash
18+
docker compose up --build
19+
```
20+
21+
## Configuration
22+
23+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
24+
25+
> Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
26+
27+
### `MISTRAL_API_KEY`
28+
An API key to access the [Mistral AI API](https://mistral.ai/).
29+
```bash
30+
defang config set MISTRAL_API_KEY
31+
```
32+
33+
## Deployment
34+
35+
> [!NOTE]
36+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
37+
38+
### Defang Playground
39+
40+
Deploy your application to the Defang Playground by opening up your terminal and typing:
41+
```bash
42+
defang compose up
43+
```
44+
45+
### BYOC
46+
47+
If you want to deploy to your own cloud account, you can [use Defang BYOC](https://docs.defang.io/docs/tutorials/deploy-to-your-cloud).
48+
49+
---
50+
51+
Title: Agentic Autogen
52+
53+
Short Description: An Autogen agent application using Mistral and FastAPI, deployed with Defang.
54+
55+
Tags: Agent, Autogen, Mistral, FastAPI, Vite, React, Python, JavaScript, AI
56+
57+
Languages: Python, JavaScript
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
services:
3+
autogen:
4+
build:
5+
context: ./src
6+
dockerfile: Dockerfile
7+
ports:
8+
- "3000:3000"
9+
environment:
10+
- MISTRAL_API_KEY=${MISTRAL_API_KEY}
11+
restart: unless-stopped
12+
healthcheck:
13+
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
14+
interval: 30s
15+
timeout: 10s
16+
retries: 3
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Default .dockerignore file for Defang
2+
**/__pycache__
3+
**/.direnv
4+
**/.DS_Store
5+
**/.envrc
6+
**/.git
7+
**/.github
8+
**/.idea
9+
**/.next
10+
**/.vscode
11+
**/compose.*.yaml
12+
**/compose.*.yml
13+
**/compose.yaml
14+
**/compose.yml
15+
**/docker-compose.*.yaml
16+
**/docker-compose.*.yml
17+
**/docker-compose.yaml
18+
**/docker-compose.yml
19+
**/node_modules
20+
**/Thumbs.db
21+
# Dockerfile
22+
# *.Dockerfile
23+
# Ignore our own binary, but only in the root to avoid ignoring subfolders
24+
defang
25+
defang.exe
26+
# Ignore our project-level state
27+
.defang

0 commit comments

Comments
 (0)