Skip to content

Commit

Permalink
Initial commit - OSS release
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikun213 committed Feb 1, 2024
0 parents commit ecbe102
Show file tree
Hide file tree
Showing 392 changed files with 65,603 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Since the ".env" file is gitignored, you can use this ".env.example" file to
# build a new ".env" file when you clone the repo. Keep this file up-to-date
# when you add new variables to `.env`.

# This file will be committed to version control, so make sure not to have any
# secrets in it. If you are cloning this repo, create a copy of this file named
# ".env" and populate it with your secrets.

#############################################
# OpenAPI variables
#############################################
OPENAI_API_KEY= # OpenAI API key
OPENAI_ORGANIZATION= # OpenAI organization ID
ENABLE_LLM_CACHE=false # flag to enable or disable LLM cache in redis

#############################################
# Authentication variables
#############################################
ENABLE_AUTH=false # flag to enable or disable authentication
NEXTAUTH_SECRET= # Add the same secret as in the FE .env file
NEXTAUTH_URL="http://localhost:3000" # Add the url as in the FE .env file

#############################################
# FastAPI environment variables
#############################################
PROJECT_NAME=agent-x
ENCRYPT_KEY=TshgGacKPYrm35m89UqbRg46JAbUm2yRtxOCQFdqa3w=
SECRET_KEY=09d25e0sas4faa6c52gf6c818166b7a9563b93f7sdsdef6f0f4caa6cf63b88e8d3e7
BACKEND_CORS_ORIGINS='["*"]' # The origins that are allowed to make cross-origin requests to your FastAPI backend.

#############################################
# PostgreSQL database environment variables
#############################################
DATABASE_HOST=database
DATABASE_USER=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=fastapi_db
DATABASE_CELERY_NAME=celery_schedule_jobs
DATABASE_PORT=5432

#############################################
# Caddy variables
#############################################
EXT_ENDPOINT1=localhost
LOCAL_1=localhost
LOCAL_2=127.0.0.1

#############################################
# Redis variables
#############################################
REDIS_HOST=redis_server
REDIS_PORT=6379

#############################################
# Minio variables
#############################################
MINIO_URL=storage.localhost
MINIO_BUCKET=fastapi-minio
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin

#############################################
# SQL Tool DB
#############################################
SQL_TOOL_DB_ENABLED="true" # Set to "true" to enable the SQL database tool.
SQL_TOOL_DB_URI='postgresql://postgres:postgres@database/postgres?connect_timeout=10' # docker url
SQL_TOOL_DB_SCHEMAS='["public"]'
SQL_TOOL_DB_INFO_PATH='app/tool_constants/sql_tool_db_info.json'
SQL_TOOL_DB_OVERWRITE_ON_START="true"

#############################################
# YAML config paths
#############################################
EXTRACTION_CONFIG_PATH='app/config/extraction.yml'
AGENT_CONFIG_PATH='app/config/agent.yml'

#############################################
# PDF Tool
#############################################
PDF_PATH='app/tool_constants/pdf_data'
PDF_TOOL_ENABLED="true"
PDF_TOOL_DATA_PATH='app/tool_constants/pdf_data' # backend/app/app/tool_constants/pdf_data for local dev
PDF_TOOL_DATABASE='pdf_indexing_1'
PDF_TOOL_EXTRACTION_CONFIG_PATH='app/config/extraction.yml' # backend/app/app/config/extraction.yml for local dev

#############################################
# Langsmith variables
#############################################
# LANGCHAIN_TRACING_V2="true"
# LANGCHAIN_ENDPOINT="https://api.langchain.plus" # change to "http://langchain-backend:1984" for self-hosted
# LANGCHAIN_API_KEY="<dummy>" # must be set to real key if using hosted - key must be set for self-hosted
# LANGCHAIN_PROJECT="default"
1 change: 1 addition & 0 deletions .github/nodejs.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.9.0
32 changes: 32 additions & 0 deletions .github/workflows/lint-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: lint-backend

on:
push:
branches:
- '**'

jobs:
lint-backend:
name: lint-backend
runs-on: Linux

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Create empty .env file
run: touch .env

- name: Install dependencies
run: |
make env-create
- name: Check linting
run: |
source backend/app/.venv/bin/activate
make lint
41 changes: 41 additions & 0 deletions .github/workflows/lint-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

name: lint-frontend

on:
push:
branches:
- '**'

defaults:
run:
working-directory: ./frontend

jobs:
lint-frontend:
name: lint-frontend
runs-on: Linux
steps:
- uses: actions/checkout@v4
- run: echo "node_version=$(cat .github/nodejs.version)" >> $GITHUB_ENV
- name: "use node ${{ env.node_version }}"
uses: actions/setup-node@v3
with:
node-version: "${{ env.node_version }}"
- name: install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install dependencies
run: pnpm install
- name: Lint check
run: pnpm lint
env:
NEXTAUTH_SECRET: bxgh3SAToI/dvtS8/FPNcJbH2Lq+KKuS3KbKvc0x6v0=
NEXTAUTH_URL: http://localhost:3000
GITHUB_ID: ${{ secrets.GH_AUTH_ID }}
GITHUB_SECRET: ${{ secrets.GH_AUTH_SECRET }}
NEXT_PUBLIC_API_URL: http://localhost:3000/api/v1
- name: Format check
run: pnpm prettier
# - name: Unit & Integration tests
# run: pnpm test
91 changes: 91 additions & 0 deletions .github/workflows/main.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Example of CI/CD pushing your images to artifactory.
# name: agent-x-app
# on:
# # Trigger the workflow on push or pull request,
# # but only for the master branch

# push:
# branches: [ main, staging ]
# tags:
# - 'v*'
# #pull_request:
# # branches: [ main ]

# jobs:
# push_to_registry:
# name: Push Docker image to Artifactory
# runs-on: [self-hosted, Linux]
# if: github.ref == 'refs/heads/main'
# steps:
# - name: Check out the repo
# uses: actions/checkout@v3

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Log in to Artifactory
# uses: docker/login-action@v2
# with:
# registry: artifactoryyourdomain.jfrog.io
# username: ${{ secrets.ARTIFACTORY_EMAIL }}
# password: ${{ secrets.ARTIFACTORY_API_KEY }}

# - name: Build and push Docker image Backend
# uses: docker/build-push-action@v3
# with:
# context: ./backend
# push: true
# tags: artifactoryyourdomain.jfrog.io/your-repository/agent-x-app-backend:latest

# - name: Build and push Docker image Frontend
# uses: docker/build-push-action@v3
# with:
# context: ./frontend
# push: true
# tags: artifactoryyourdomain.jfrog.io/your-repository/agent-x-app-frontend:latest
# build-args: |
# GITHUB_ID=${{ secrets.OAUTH_GITHUB_ID }}
# GITHUB_SECRET=${{ secrets.OAUTH_GITHUB_SECRET }}
# NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}
# NEXTAUTH_URL=https://your.domain.com
# NEXT_PUBLIC_API_URL=https://your.domain.com/api/v1

# push_to_registry_staging:
# name: Push Docker image to Artifactory Staging
# runs-on: [self-hosted, Linux]
# if: github.ref == 'refs/heads/staging'
# steps:
# - name: Check out the repo
# uses: actions/checkout@v3
# with:
# ref: staging

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1

# - name: Log in to Artifactory
# uses: docker/login-action@v2
# with:
# registry: artifactoryyourdomain.jfrog.io
# username: ${{ secrets.ARTIFACTORY_EMAIL }}
# password: ${{ secrets.ARTIFACTORY_API_KEY }}

# - name: Build and push Docker image Backend Staging
# uses: docker/build-push-action@v3
# with:
# context: ./backend
# push: true
# tags: artifactoryyourdomain.jfrog.io/your-repository/agent-x-app-backend-staging:latest

# - name: Build and push Docker image Frontend Staging
# uses: docker/build-push-action@v3
# with:
# context: ./frontend
# push: true
# tags: artifactoryyourdomain.jfrog.io/your-repository/agent-x-app-frontend-staging:latest
# build-args: |
# GITHUB_ID=${{ secrets.OAUTH_GITHUB_ID }}
# GITHUB_SECRET=${{ secrets.OAUTH_GITHUB_SECRET }}
# NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}
# NEXTAUTH_URL=https://your.domain.com
# NEXT_PUBLIC_API_URL=https://your.domain.com/api/v1
128 changes: 128 additions & 0 deletions .github/workflows/nextjs_bundle_analysis.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# # Copyright (c) HashiCorp, Inc.
# # SPDX-License-Identifier: MPL-2.0

# name: 'Next.js Bundle Analysis'

# on:
# pull_request:
# branches:
# - develop
# - staging
# - main

# defaults:
# run:
# working-directory: ./frontend

# permissions:
# contents: read # for checkout repository
# actions: read # for fetching base branch bundle stats
# pull-requests: write # for comments

# jobs:
# analyze:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3

# - name: Install Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 18

# - name: Install dependencies
# uses: bahmutov/npm-install@v1

# # If pnpm is used, you need to switch the previous step with the following one. pnpm does not create a package-lock.json
# # so the step above will fail to pull dependencies
# # - uses: pnpm/action-setup@v2
# # name: Install pnpm
# # id: pnpm-install
# # with:
# # version: 7
# # run_install: true

# - name: Restore next build
# uses: actions/cache@v3
# id: restore-build-cache
# env:
# cache-name: cache-next-build
# with:
# # if you use a custom build directory, replace all instances of `.next` in this file with your build directory
# # ex: if your app builds to `dist`, replace `.next` with `dist`
# path: .next/cache
# # change this if you prefer a more strict cache
# key: ${{ runner.os }}-build-${{ env.cache-name }}

# - name: Build next.js app
# # change this if your site requires a custom build command
# run: ./node_modules/.bin/next build

# # Here's the first place where next-bundle-analysis' own script is used
# # This step pulls the raw bundle stats for the current bundle
# - name: Analyze bundle
# run: npx -p nextjs-bundle-analysis report

# - name: Upload bundle
# uses: actions/upload-artifact@v3
# with:
# name: bundle
# path: .next/analyze/__bundle_analysis.json

# - name: Download base branch bundle stats
# uses: dawidd6/action-download-artifact@v2
# if: success() && github.event.number
# with:
# workflow: nextjs_bundle_analysis.yml
# branch: ${{ github.event.pull_request.base.ref }}
# path: .next/analyze/base

# # And here's the second place - this runs after we have both the current and
# # base branch bundle stats, and will compare them to determine what changed.
# # There are two configurable arguments that come from package.json:
# #
# # - budget: optional, set a budget (bytes) against which size changes are measured
# # it's set to 350kb here by default, as informed by the following piece:
# # https://infrequently.org/2021/03/the-performance-inequality-gap/
# #
# # - red-status-percentage: sets the percent size increase where you get a red
# # status indicator, defaults to 20%
# #
# # Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
# # entry in your package.json file.
# - name: Compare with base branch bundle
# if: success() && github.event.number
# run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare

# - name: Get Comment Body
# id: get-comment-body
# if: success() && github.event.number
# # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
# run: |
# echo "body<<EOF" >> $GITHUB_OUTPUT
# echo "$(cat .next/analyze/__bundle_analysis_comment.txt)" >> $GITHUB_OUTPUT
# echo EOF >> $GITHUB_OUTPUT

# - name: Find Comment
# uses: peter-evans/find-comment@v2
# if: success() && github.event.number
# id: fc
# with:
# issue-number: ${{ github.event.number }}
# body-includes: '<!-- __NEXTJS_BUNDLE -->'

# - name: Create Comment
# uses: peter-evans/create-or-update-comment@v2
# if: success() && github.event.number && steps.fc.outputs.comment-id == 0
# with:
# issue-number: ${{ github.event.number }}
# body: ${{ steps.get-comment-body.outputs.body }}

# - name: Update Comment
# uses: peter-evans/create-or-update-comment@v2
# if: success() && github.event.number && steps.fc.outputs.comment-id != 0
# with:
# issue-number: ${{ github.event.number }}
# body: ${{ steps.get-comment-body.outputs.body }}
# comment-id: ${{ steps.fc.outputs.comment-id }}
# edit-mode: replace
Loading

0 comments on commit ecbe102

Please sign in to comment.