Skip to content

Commit

Permalink
Initial commit with backup files
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinHsu1019 committed Nov 10, 2024
0 parents commit f768649
Show file tree
Hide file tree
Showing 32 changed files with 1,251 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
pull_request:
branches:
- '**'
push:
branches:
- '**'

jobs:
lint_job:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install setuptools -U
python -m pip install pre-commit
- name: Run pre-commit
run: |
pre-commit run --all-files || (git --no-pager diff && exit 1)
169 changes: 169 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# secret ini
config.ini

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Mac
.DS_Store

# php
vendor
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
default_stages: [commit, push]
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# check and format the syntax
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
- id: check-yaml
exclude: ^deployment/kubernetes/charts
- id: check-toml
- id: check-xml
# environment checker
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# check the git-related commit or object
- id: check-merge-conflict
- id: check-added-large-files
# check sensitive information
- id: debug-statements
- id: detect-private-key
- repo: https://github.com/zricethezav/gitleaks
rev: v8.18.1
hooks:
- id: gitleaks
# run the detect mode and show all the leak credentials
entry: gitleaks detect --verbose --redact
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint-docker
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
language_version: python3.12
args:
- --target-version=py312
- --line-length=120
- --skip-string-normalization
18 changes: 18 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
line-length = 120


[lint]
select = [
"E", # pycodestyle error
"W", # pycodestyle warning
"F", # Pyflakes
"B", # bugbear
"UP", # pyupgrade
"N", # pep8-naming
"I001", # isort
"Q000", # flake8-quotes
]
ignore-init-module-imports = true

[lint.flake8-quotes]
inline-quotes = "single"
110 changes: 110 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# AI CUP 2024 玉山人工智慧公開挑戰賽-RAG與LLM在金融問答的應用

## Result

- Total: 38 / 487 Teams
- Leaderboard: 38 / 222

![AI Cup Result](img/aicup_result.png)

## Development Mode
To set up the development environment, follow these steps:

1. Create a virtual environment:
```
python3 -m venv aicup_venv
source aicup_venv/bin/activate
```

2. Install the required dependencies:
```
pip install -r requirements.txt
```

3. Copy the configuration example and create your own config file:
```
cp config_example.ini config.ini
```

4. Manually add your `secret key` to the `config.ini`.

5. Create a `logs` directory:
```
mkdir logs
```

6. Navigate to the `docker` directory (optional):
```
cd docker
```

7. Start the Docker environment (optional):
```
docker-compose up -d
```

8. Run the Flask app:
```
python3 src/flask_app.py
```

## Docker Production Mode

1. Copy the configuration example and create your own config file:
```
cp config_example.ini config.ini
```

2. Manually add your `secret key` to the `config.ini`.

3. Create a `logs` directory:
```
mkdir logs
```

4. Navigate to the `docker` directory:
```
cd docker
```

5. Start the Docker environment:
```
docker-compose up -d
```

6. Build the Docker image:
```
docker build -t aicup_img -f dockerfile .
```

7. Run the Docker container:
```
docker run -d -p 5001:5001 --name aicup_cont aicup_img
```

## Folder-specific Details
For more detailed information about each folder and its purpose, refer to the individual `README.md` files located in their respective directories.

## Contribution Guide (Optional)
We follow GitHub Flow for contributing. The steps are as follows:

1. **Claim an issue**: Start by picking an issue from GitHub.
2. **Create a branch**: Open a new branch with a clear name related to the issue (e.g., `feat/xxxxx-feature`).
3. **Development**: After completing the feature, ensure you run pre-commit hooks:
```
pre-commit run --all-files
```
4. **Create PR Request (PR)**:
- Ensure your PR is small and easily reviewable.
- Add the GitHub issue number to the PR title in the format `feat(#123): xxxxxx` for easy reference.
- Write a clear description including the reason for the change and what was modified (`Reason & Changes`).
5. **Review & Approval**:
- Assign the PR to all members of the team for review.
- Wait for at least one approval.
- Ensure all CI checks pass.
6. **Merge**: Once approved and CI passes, merge the branch into `main` yourself.

## Additional Notes (Optional)
- Keep your commits focused and ensure meaningful commit messages.
- Always rebase your branch on top of `main` before merging.
- Avoid large, multi-purpose PRs. Smaller changes are easier to review and help prevent issues.
12 changes: 12 additions & 0 deletions config_example.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Weaviate]
weaviate_url =
classnm =

[Gemini]
api_key =

[OpenAI]
api_key =

[Api_docs]
password =
1 change: 1 addition & 0 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Data that needs to be saved in Weaviate
Loading

0 comments on commit f768649

Please sign in to comment.