Skip to content

Commit

Permalink
Add cc generated projects without auth
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Nov 13, 2024
1 parent 71a307b commit e54c58e
Show file tree
Hide file tree
Showing 123 changed files with 2,991 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
from fastagency.adapters.fastapi import FastAPIAdapter
from fastagency.app import FastAgency
from fastagency.ui.mesop import MesopUI
from fastagency.ui.mesop.auth.basic_auth import BasicAuth

fastapi_url = "http://localhost:8008"

provider = FastAPIAdapter.create_provider(
fastapi_url=fastapi_url,
)
ui = MesopUI()
auth = BasicAuth(
# TODO: Replace `allowed_users` with the desired usernames and their
# bcrypt-hashed passwords. One way to generate bcrypt-hashed passwords
# is by using online tools such as https://bcrypt.online
# Default password for all users is `password`
allowed_users={
"admin": "$2y$10$ZgcGQlsvMoMRmmW4Y.nUVuVHc.vOJsOA7iXAPXWPFy9DX2S7oeTDa", # nosemgrep: generic.secrets.security.detected-bcrypt-hash.detected-bcrypt-hash
"[email protected]": "$2y$10$ZgcGQlsvMoMRmmW4Y.nUVuVHc.vOJsOA7iXAPXWPFy9DX2S7oeTDa", # nosemgrep: generic.secrets.security.detected-bcrypt-hash.detected-bcrypt-hash
},
)

ui = MesopUI(auth=auth)


app = FastAgency(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.1.0"
name = "my_fastagency_app"

dependencies = [
"fastagency[autogen,mesop,server,fastapi]>=0.3.0",
"fastagency[autogen,mesop,server,fastapi,basic_auth]>=0.3.0",
]

[project.optional-dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONTAINER_PREFIX=${USER}

# LLM keys
# Set atleast one of the following keys
OPENAI_API_KEY=${OPENAI_API_KEY}
TOGETHER_API_KEY=${TOGETHER_API_KEY}
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "python-3.12",
"dockerComposeFile": [
"./docker-compose.yml"
],
"service": "python-3.12-my_fastagency_app_without_auth",

"secrets": {
"OPENAI_API_KEY": {
"description": "This key is optional and only needed if you are working on OpenAI-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"TOGETHER_API_KEY": {
"description": "This key is optional and only needed if you are working with Together API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"ANTHROPIC_API_KEY": {
"description": "This key is optional and only needed if you are working with Anthropic API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
}
},
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspaces/my_fastagency_app_without_auth",
// "runArgs": [],
"remoteEnv": {},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"configureZshAsDefaultShell": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000"
// "upgradePackages": "true"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"updateContentCommand": "bash .devcontainer/setup.sh",
"postCreateCommand": [],
"customizations": {
"vscode": {
"settings": {
"python.linting.enabled": true,
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"[python]": {
"editor.defaultFormatter": "ms-python.vscode-pylance"
},
"editor.rulers": [
80
]
},
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-python.vscode-pylance"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'

services:
# nosemgrep: yaml.docker-compose.security.writable-filesystem-service.writable-filesystem-service
python-3.12-my_fastagency_app_without_auth:
image: mcr.microsoft.com/devcontainers/python:3.12
container_name: my_fastagency_app_without_auth-${USER}-python-3.12
volumes:
- ../:/workspaces/my_fastagency_app_without_auth:cached
command: sleep infinity

env_file:
- ./devcontainer.env
security_opt:
- no-new-privileges:true
networks:
- my_fastagency_app_without_auth-network

networks:
my_fastagency_app_without_auth-network:
name: my_fastagency_app_without_auth-${USER}-network
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# update pip
pip install --upgrade pip

# install dev packages
pip install -e ".[dev]"

# install fly.io CLI and set fly.io CLI PATH in bashrc and zshrc
curl -L https://fly.io/install.sh | sh
echo 'export FLYCTL_INSTALL="/home/vscode/.fly"' | tee -a ~/.bashrc ~/.zshrc
echo 'export PATH="$FLYCTL_INSTALL/bin:$PATH"' | tee -a ~/.bashrc ~/.zshrc

# check OPENAI_API_KEY environment variable is set
if [ -z "$OPENAI_API_KEY" ]; then
echo
echo -e "\033[33mWarning: OPENAI_API_KEY environment variable is not set.\033[0m"
echo
fi
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# Python
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

name: Test

on:
push:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
python-version: ["3.12"]
fail-fast: false
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[testing]
- name: Check for OPENAI_API_KEY
run: |
if [ -z "${{ secrets.OPENAI_API_KEY }}" ]; then
echo "Error: OPENAI_API_KEY is not set in GitHub secrets."
echo "Please set the OPENAI_API_KEY secret in your repository settings."
echo "Follow the instructions here:"
echo "https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository"
exit 1
fi
- name: Run tests
run: pytest
env:
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
__pycache__
dist
.idea
venv*
.venv*
.env
.env*
*.lock
.vscode
.pypirc
.pytest_cache
.ruff_cache
.mypy_cache
.coverage*
.cache
htmlcov
token
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: local
hooks:
- id: lint
name: Linter
entry: "scripts/lint-pre-commit.sh"
language: python
# language_version: python3.12
types: [python]
require_serial: true
verbose: true

- repo: local
hooks:
- id: static-analysis
name: Static analysis
entry: "scripts/static-pre-commit.sh"
language: python
# language_version: python3.12
types: [python]
require_serial: true
verbose: true

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ["--baseline", ".secrets.baseline"]
Loading

0 comments on commit e54c58e

Please sign in to comment.