Skip to content

Commit

Permalink
Merge pull request #437 from airtai/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
davorrunje authored Jun 26, 2024
2 parents b7c9ff3 + d71f22b commit bd4637f
Show file tree
Hide file tree
Showing 30 changed files with 699 additions and 150 deletions.
8 changes: 6 additions & 2 deletions .devcontainer/devcontainer.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
PORT_PREFIX=${PORT_PREFIX}
CONTAINER_PREFIX=${USER}
AZURE_OPENAI_API_KEY=${AZURE_OPENAI_API_KEY}
AZURE_API_ENDPOINT=${AZURE_API_ENDPOINT}
AZURE_GPT35_MODEL=${AZURE_GPT35_MODEL}
AZURE_API_VERSION=${AZURE_API_VERSION}
TOGETHER_API_KEY=${TOGETHER_API_KEY}
ADMIN_EMAILS=${ADMIN_EMAILS}
GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}

# LLM keys
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
AZURE_OPENAI_API_KEY=${AZURE_OPENAI_API_KEY}
OPENAI_API_KEY=${OPENAI_API_KEY}
TOGETHER_API_KEY=${TOGETHER_API_KEY}
27 changes: 23 additions & 4 deletions .github/workflows/deploy-nats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,41 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
detect-deployment-environment:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- name: Determine deployment environment
id: set-env
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "::set-output name=environment::production"
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "::set-output name=environment::staging"
else
echo "::set-output name=environment::none"
fi
deploy_nats:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
needs:
- detect-deployment-environment
if: github.ref_name == 'main' || github.ref_name == 'dev'
environment:
name: ${{ needs.detect-deployment-environment.outputs.environment }}
env:
CLEAR_JETSTREAM: ${{ github.event.inputs.clear_jetstream }}

GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DEVELOPER_TOKEN: ${{ secrets.DEVELOPER_TOKEN }}
DATABASE_URL: ${{ github.ref_name == 'main' && secrets.PROD_DATABASE_URL || secrets.STAGING_DATABASE_URL }}
PY_DATABASE_URL: ${{ github.ref_name == 'main' && secrets.PROD_PY_DATABASE_URL || secrets.STAGING_PY_DATABASE_URL }}
DOMAIN: ${{ github.ref_name == 'main' && vars.PROD_DOMAIN || vars.STAGING_DOMAIN }}
SSH_KEY: ${{ github.ref_name == 'main' && secrets.PROD_SSH_KEY || secrets.STAGING_SSH_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
PY_DATABASE_URL: ${{ secrets.PY_DATABASE_URL }}
DOMAIN: ${{ vars.DOMAIN }}
SSH_KEY: ${{ secrets.SSH_KEY }}
steps:
- uses: actions/checkout@v3 # Don't change it to cheackout@v4. V4 is not working with container image.
# This is to fix GIT not liking owner of the checkout dir - https://github.com/actions/runner/issues/2033#issuecomment-1204205989
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Smokeshow

on:
workflow_run:
workflows: [Test]
workflows: [Pipeline]
types: [completed]


Expand All @@ -22,7 +22,7 @@ jobs:

- run: pip install smokeshow

- uses: dawidd6/action-download-artifact@v3.1.4 # nosemgrep
- uses: dawidd6/action-download-artifact@v6 # nosemgrep
with:
workflow: test.yaml
commit: ${{ github.event.workflow_run.head_sha }}
Expand Down
134 changes: 73 additions & 61 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ env:
IMAGE_NAME: ${{ github.repository }}

jobs:
detect-deployment-environment:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- name: Determine deployment environment
id: set-env
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "environment=production" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "environment=staging" >> $GITHUB_OUTPUT
else
echo "environment=none" >> $GITHUB_OUTPUT
fi
static_analysis:
strategy:
matrix:
Expand Down Expand Up @@ -41,6 +56,7 @@ jobs:

test:
runs-on: ubuntu-latest
environment: testing
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
Expand Down Expand Up @@ -73,13 +89,13 @@ jobs:
DATABASE_URL: postgresql://admin:password@localhost:5432/fastagency
PY_DATABASE_URL: postgresql://admin:password@localhost:5433/pyfastagency
NATS_URL: nats://localhost:4222
AZURE_API_VERSION: ${{ secrets.STAGING_AZURE_API_VERSION }}
AZURE_API_ENDPOINT: ${{ secrets.STAGING_AZURE_API_ENDPOINT }}
AZURE_GPT4_MODEL: ${{ secrets.STAGING_AZURE_GPT4_MODEL }}
AZURE_GPT35_MODEL: ${{ secrets.STAGING_AZURE_GPT35_MODEL }}
AZURE_OPENAI_API_KEY: ${{ secrets.STAGING_AZURE_OPENAI_API_KEY }}
TOGETHER_API_KEY: ${{ secrets.STAGING_TOGETHER_API_KEY }}
OPENAI_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_OPENAI_API_KEY || secrets.STAGING_OPENAI_API_KEY }}
AZURE_API_VERSION: ${{ vars.AZURE_API_VERSION }}
AZURE_API_ENDPOINT: ${{ vars.AZURE_API_ENDPOINT }}
AZURE_GPT35_MODEL: ${{ vars.AZURE_GPT35_MODEL }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down Expand Up @@ -114,7 +130,14 @@ jobs:
- run: mkdir coverage
- name: Prisma
run: prisma migrate deploy && prisma generate
- name: Test
- name: Test without LLMs
if: matrix.python-version != '3.12'
run: bash scripts/test.sh -m "not (anthropic or azure_oai or openai or togetherai)"
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
- name: Test with LLMs
if: matrix.python-version == '3.12'
run: bash scripts/test.sh
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
Expand All @@ -129,16 +152,6 @@ jobs:
test-macos-latest:
if: github.event.pull_request.draft == false
runs-on: macos-latest
env:
NATS_URL: nats://localhost:4222
AZURE_API_VERSION: ${{ secrets.STAGING_AZURE_API_VERSION }}
AZURE_API_ENDPOINT: ${{ secrets.STAGING_AZURE_API_ENDPOINT }}
AZURE_GPT4_MODEL: ${{ secrets.STAGING_AZURE_GPT4_MODEL }}
AZURE_GPT35_MODEL: ${{ secrets.STAGING_AZURE_GPT35_MODEL }}
AZURE_OPENAI_API_KEY: ${{ secrets.STAGING_AZURE_OPENAI_API_KEY }}
TOGETHER_API_KEY: ${{ secrets.STAGING_TOGETHER_API_KEY }}
OPENAI_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_OPENAI_API_KEY || secrets.STAGING_OPENAI_API_KEY }}
AUTOGEN_USE_DOCKER: False
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -154,21 +167,11 @@ jobs:
- name: Prisma
run: prisma generate
- name: Test
run: bash scripts/test.sh -m "not db and not nats"
run: bash scripts/test.sh -m "not (db or nats or anthropic or azure_oai or openai or togetherai)"

test-windows-latest:
if: github.event.pull_request.draft == false
runs-on: windows-latest
env:
NATS_URL: nats://localhost:4222
AZURE_API_VERSION: ${{ secrets.STAGING_AZURE_API_VERSION }}
AZURE_API_ENDPOINT: ${{ secrets.STAGING_AZURE_API_ENDPOINT }}
AZURE_GPT4_MODEL: ${{ secrets.STAGING_AZURE_GPT4_MODEL }}
AZURE_GPT35_MODEL: ${{ secrets.STAGING_AZURE_GPT35_MODEL }}
AZURE_OPENAI_API_KEY: ${{ secrets.STAGING_AZURE_OPENAI_API_KEY }}
TOGETHER_API_KEY: ${{ secrets.STAGING_TOGETHER_API_KEY }}
OPENAI_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_OPENAI_API_KEY || secrets.STAGING_OPENAI_API_KEY }}
AUTOGEN_USE_DOCKER: False
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -184,7 +187,7 @@ jobs:
- name: Prisma
run: prisma generate
- name: Test
run: bash scripts/test.sh -m "not db and not nats"
run: bash scripts/test.sh -m "not (db or nats or anthropic or azure_oai or openai or togetherai)"

coverage-combine:
if: github.event.pull_request.draft == false
Expand Down Expand Up @@ -328,7 +331,6 @@ jobs:
runs-on: ubuntu-latest
env:
SKIP: "static-analysis"
TOGETHER_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_TOGETHER_API_KEY || secrets.STAGING_TOGETHER_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down Expand Up @@ -371,23 +373,25 @@ jobs:
defaults:
run:
shell: bash
needs: [check]
needs:
- check
- detect-deployment-environment
if: github.ref_name == 'main' || github.ref_name == 'dev'
environment:
name: ${{ needs.detect-deployment-environment.outputs.environment }}
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
DEVELOPER_TOKEN: ${{ secrets.DEVELOPER_TOKEN }}
DATABASE_URL: ${{ github.ref_name == 'main' && secrets.PROD_DATABASE_URL || secrets.STAGING_DATABASE_URL }}
PY_DATABASE_URL: ${{ github.ref_name == 'main' && secrets.PROD_PY_DATABASE_URL || secrets.STAGING_PY_DATABASE_URL }}
FASTAGENCY_SERVER_URL: ${{ github.ref_name == 'main' && vars.PROD_FASTAGENCY_SERVER_URL || vars.STAGING_FASTAGENCY_SERVER_URL }}
DOMAIN: ${{ github.ref_name == 'main' && vars.PROD_DOMAIN || vars.STAGING_DOMAIN }}
SSH_KEY: ${{ github.ref_name == 'main' && secrets.PROD_SSH_KEY || secrets.STAGING_SSH_KEY }}
AZURE_API_VERSION: ${{ github.ref_name == 'main' && secrets.PROD_AZURE_API_VERSION || secrets.STAGING_AZURE_API_VERSION }}
AZURE_API_ENDPOINT: ${{ github.ref_name == 'main' && secrets.PROD_AZURE_API_ENDPOINT || secrets.STAGING_AZURE_API_ENDPOINT }}
AZURE_GPT35_MODEL: ${{ github.ref_name == 'main' && secrets.PROD_AZURE_GPT35_MODEL || secrets.STAGING_AZURE_GPT35_MODEL }}
AZURE_OPENAI_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_AZURE_OPENAI_API_KEY || secrets.STAGING_AZURE_OPENAI_API_KEY }}
TOGETHER_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_TOGETHER_API_KEY || secrets.STAGING_TOGETHER_API_KEY }}
OPENAI_API_KEY: ${{ github.ref_name == 'main' && secrets.PROD_OPENAI_API_KEY || secrets.STAGING_OPENAI_API_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
PY_DATABASE_URL: ${{ secrets.PY_DATABASE_URL }}
FASTAGENCY_SERVER_URL: ${{ vars.FASTAGENCY_SERVER_URL }}
DOMAIN: ${{ vars.DOMAIN }}
SSH_KEY: ${{ secrets.SSH_KEY }}
AZURE_API_VERSION: ${{ vars.AZURE_API_VERSION }}
AZURE_API_ENDPOINT: ${{ vars.AZURE_API_ENDPOINT }}
AZURE_GPT35_MODEL: ${{ vars.AZURE_GPT35_MODEL }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}

steps:
- uses: actions/checkout@v3 # Don't change it to cheackout@v4. V4 is not working with container image.
Expand Down Expand Up @@ -416,25 +420,29 @@ jobs:
defaults:
run:
shell: bash
needs: [deploy_fastapi]
needs:
- deploy_fastapi
- detect-deployment-environment
if: github.ref_name == 'main' || github.ref_name == 'dev'
environment:
name: ${{ needs.detect-deployment-environment.outputs.environment }}
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
PORT: ${{ vars.PORT }}
# REACT_APP_CUSTOMER_PORTAL_LINK: ${{ github.ref_name == 'main' && vars.PROD_REACT_APP_CUSTOMER_PORTAL_LINK || vars.STAGING_REACT_APP_CUSTOMER_PORTAL_LINK }}
GOOGLE_CLIENT_ID: ${{ github.ref_name == 'main' && secrets.PROD_GOOGLE_CLIENT_ID || secrets.STAGING_GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ github.ref_name == 'main' && secrets.PROD_GOOGLE_CLIENT_SECRET || secrets.STAGING_GOOGLE_CLIENT_SECRET }}
# REACT_APP_CUSTOMER_PORTAL_LINK: ${{ vars.REACT_APP_CUSTOMER_PORTAL_LINK }}
GOOGLE_CLIENT_ID: ${{ vars.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
ADMIN_EMAILS: ${{ vars.ADMIN_EMAILS }}
WASP_SERVER_URL: ${{ github.ref_name == 'main' && vars.PROD_WASP_SERVER_URL || vars.STAGING_WASP_SERVER_URL }}
FASTAGENCY_SERVER_URL: ${{ github.ref_name == 'main' && vars.PROD_FASTAGENCY_SERVER_URL || vars.STAGING_FASTAGENCY_SERVER_URL }}
NODE_DOMAIN: ${{ github.ref_name == 'main' && vars.PROD_NODE_DOMAIN || vars.STAGING_NODE_DOMAIN }}
WASP_WEB_CLIENT_URL: ${{ github.ref_name == 'main' && vars.PROD_WASP_WEB_CLIENT_URL || vars.STAGING_WASP_WEB_CLIENT_URL }}
DATABASE_URL: ${{ github.ref_name == 'main' && secrets.PROD_DATABASE_URL || secrets.STAGING_DATABASE_URL }}
REACT_APP_API_URL: ${{ github.ref_name == 'main' && vars.PROD_REACT_APP_API_URL || vars.STAGING_REACT_APP_API_URL }}
JWT_SECRET: ${{ github.ref_name == 'main' && secrets.PROD_JWT_SECRET || secrets.STAGING_JWT_SECRET }}
# STRIPE_WEBHOOK_SECRET: ${{ github.ref_name == 'main' && secrets.PROD_STRIPE_WEBHOOK_SECRET || secrets.STAGING_STRIPE_WEBHOOK_SECRET }}
SSH_KEY: ${{ github.ref_name == 'main' && secrets.PROD_SSH_KEY || secrets.STAGING_SSH_KEY }}
WASP_SERVER_URL: ${{ vars.WASP_SERVER_URL }}
FASTAGENCY_SERVER_URL: ${{ vars.FASTAGENCY_SERVER_URL }}
NODE_DOMAIN: ${{ vars.NODE_DOMAIN }}
WASP_WEB_CLIENT_URL: ${{ vars.WASP_WEB_CLIENT_URL }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
REACT_APP_API_URL: ${{ vars.REACT_APP_API_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
# STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
SSH_KEY: ${{ secrets.SSH_KEY }}
steps:
- name: Checkout repository with cached git lfs
uses: nschloe/action-cached-lfs-checkout@v1
Expand Down Expand Up @@ -462,13 +470,17 @@ jobs:
runs-on: ubuntu-22.04
permissions:
contents: write
needs: [deploy_fastapi]
needs:
- deploy_fastapi
- detect-deployment-environment
if: github.ref_name == 'main' || github.ref_name == 'dev'
environment:
name: ${{ needs.detect-deployment-environment.outputs.environment }}
env:
NODE_DOMAIN: ${{ github.ref_name == 'main' && vars.PROD_NODE_DOMAIN || vars.STAGING_NODE_DOMAIN }}
SSH_KEY: ${{ github.ref_name == 'main' && secrets.PROD_SSH_KEY || secrets.STAGING_SSH_KEY }}
# REACT_APP_CUSTOMER_PORTAL_LINK: ${{ github.ref_name == 'main' && vars.PROD_REACT_APP_CUSTOMER_PORTAL_LINK || vars.STAGING_REACT_APP_CUSTOMER_PORTAL_LINK }}
REACT_APP_API_URL: ${{ github.ref_name == 'main' && vars.PROD_REACT_APP_API_URL || vars.STAGING_REACT_APP_API_URL }}
NODE_DOMAIN: ${{ vars.NODE_DOMAIN }}
SSH_KEY: ${{ secrets.SSH_KEY }}
# REACT_APP_CUSTOMER_PORTAL_LINK: ${{ vars.REACT_APP_CUSTOMER_PORTAL_LINK }}
REACT_APP_API_URL: ${{ vars.REACT_APP_API_URL }}
steps:
- name: Checkout repository with cached git lfs
uses: nschloe/action-cached-lfs-checkout@v1
Expand Down
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@
"filename": ".github/workflows/test.yaml",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 58,
"line_number": 74,
"is_secret": false
},
{
"type": "Basic Auth Credentials",
"filename": ".github/workflows/test.yaml",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 73,
"line_number": 89,
"is_secret": false
}
],
Expand All @@ -141,5 +141,5 @@
}
]
},
"generated_at": "2024-05-29T09:18:25Z"
"generated_at": "2024-06-26T04:43:53Z"
}
4 changes: 4 additions & 0 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ search:
- [chat](api/fastagency/app/chat.md)
- [create_toolbox_for_new_user](api/fastagency/app/create_toolbox_for_new_user.md)
- [deployment_chat](api/fastagency/app/deployment_chat.md)
- [deployment_ping](api/fastagency/app/deployment_ping.md)
- [generate_chat_name](api/fastagency/app/generate_chat_name.md)
- [get_all_models](api/fastagency/app/get_all_models.md)
- [get_azure_llm_client](api/fastagency/app/get_azure_llm_client.md)
Expand Down Expand Up @@ -72,6 +73,9 @@ search:
- deployment
- [Deployment](api/fastagency/models/deployments/deployment/Deployment.md)
- llms
- anthropic
- [Anthropic](api/fastagency/models/llms/anthropic/Anthropic.md)
- [AnthropicAPIKey](api/fastagency/models/llms/anthropic/AnthropicAPIKey.md)
- azure
- [AzureOAI](api/fastagency/models/llms/azure/AzureOAI.md)
- [AzureOAIAPIKey](api/fastagency/models/llms/azure/AzureOAIAPIKey.md)
Expand Down
11 changes: 11 additions & 0 deletions docs/docs/en/api/fastagency/app/deployment_ping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: fastagency.app.deployment_ping
11 changes: 11 additions & 0 deletions docs/docs/en/api/fastagency/models/llms/anthropic/Anthropic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: fastagency.models.llms.anthropic.Anthropic
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: fastagency.models.llms.anthropic.AnthropicAPIKey
7 changes: 7 additions & 0 deletions fastagency/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,10 @@ async def deployment_chat(deployment_uuid: str) -> Dict[str, Any]:
"team_uuid": team_uuid,
"conversation_name": "New Chat",
}


@app.get("/deployment/{deployment_uuid}/ping")
async def deployment_ping() -> Dict[str, str]:
return {
"status": "ok",
}
Loading

0 comments on commit bd4637f

Please sign in to comment.