Skip to content

Commit

Permalink
🎉 add repository files
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineDjeghri committed Dec 7, 2024
1 parent a38f8ab commit 573eb68
Show file tree
Hide file tree
Showing 83 changed files with 20,039 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -- DEV MODE if true, log debugs and traces
DEV_MODE=True

# Ollama and ollamazure models to emulate openai or azure_openai
# run make run-ollama or make run-ollamazure to emulate openai or azure_openai locally
OLLAMA_MODEL_NAME="phi3:3.8b-mini-4k-instruct-q4_K_M"
OLLAMA_EMBEDDING_MODEL_NAME="all-minilm:l6-v2"


# LLM_PROVIDER : openai or azure_openai
LLM_PROVIDER="openai"

# if provider is OPENAI
OPENAI_DEPLOYMENT_NAME="phi3:3.8b-mini-4k-instruct-q4_K_M" # or gpt-4o-mini if you use openai
OPENAI_BASE_URL="http://localhost:11434/v1" # ollama endpoint or https://api.openai.com/v1 if use use openai
OPENAI_API_KEY="t"
# if provider is AZURE
AZURE_OPENAI_DEPLOYMENT_NAME="phi3:3.8b-mini-4k-instruct-q4_K_M" # or your azure model name
AZURE_OPENAI_API_KEY="t" #
AZURE_OPENAI_BASE_URL="http://localhost:4041" # ollamazure endpoint or your azure endpoint
AZURE_OPENAI_API_VERSION="2024-10-01-preview" # fake api version

# -- FASTAPI
FASTAPI_HOST="localhost"
FASTAPI_PORT=8080
# -- Streamlit
STREAMLIT_PORT=8501

####################### EVALUATION ############################
# (Optional) If you want to use Promptfoo and ragas, the eval tool
ENABLE_EVALUATION=false # if true, you need to set the following
# LLMAAJ stands for LLM as a judge
LLMAAJ_PROVIDER="openai" # or azure_openai
#if openai
LLMAAJ_OPENAI_DEPLOYMENT_NAME="phi3:3.8b-mini-4k-instruct-q4_K_M" # or gpt-4o-mini if you use openai
LLMAAJ_OPENAI_BASE_URL="http://localhost:11434/v1" # ollama endpoint or https://api.openai.com/v1 if use use openai
LLMAAJ_OPENAI_API_KEY="t"
LLMAAJ_OPENAI_EMBEDDING_DEPLOYMENT_NAME="text-embedding-ada-002"
#if azure_openai
LLMAAJ_AZURE_OPENAI_DEPLOYMENT_NAME="phi3:3.8b-mini-4k-instruct-q4_K_M" # or your azure model name
LLMAAJ_AZURE_OPENAI_API_KEY="t"
LLMAAJ_AZURE_OPENAI_BASE_URL="http://localhost:4041" # ollamazure endpoint or your azure endpoint
LLMAAJ_AZURE_OPENAI_API_VERSION="2024-10-01-preview"
LLMAAJ_AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME="all-minilm:l6-v2" # or your azure embedding model name


####################### AI SEARCH ############################
# (Optional) If you want to use Azure Search AI
ENABLE_AZURE_SEARCH=false # if true, you need to set the following
AZURE_SEARCH_TOP_K=3
AZURE_SEARCH_API_KEY=""
AZURE_SEARCH_INDEX_NAME=""
AZURE_SEARCH_INDEXER_NAME=""
AZURE_SEARCH_SERVICE_ENDPOINT=""
SEMENTIC_CONFIGURATION_NAME=""
# -- AZURE BLOB STORAGE
AZURE_STORAGE_ACCOUNT_NAME=""
AZURE_STORAGE_ACCOUNT_KEY=""
AZURE_CONTAINER_NAME=""
62 changes: 62 additions & 0 deletions .github/workflows/ai_evaluation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'LLM Evaluation'

on:
pull_request:
push:
#on:
# pull_request:
# paths:
# - src/ml
# - src/evaluation

env:
OLLAMA_MODEL_NAME: "phi3:3.8b-mini-4k-instruct-q4_K_M"
OLLAMA_EMBEDDING_MODEL_NAME: "all-minilm:l6-v2"
LLM_PROVIDER: "openai"
OPENAI_DEPLOYMENT_NAME: "phi3:3.8b-mini-4k-instruct-q4_K_M" # or gpt-4o-mini if you use openai
OPENAI_BASE_URL: "http://localhost:11434/v1" # ollama endpoint or https://api.openai.com/v1 if use use openai
OPENAI_API_KEY: "t"

ENABLE_EVALUATION: true # if true, you need to set the following
# LLMAAJ stands for LLM as a judge
LLMAAJ_PROVIDER: "openai" # or azure_openai
#if openai
LLMAAJ_OPENAI_DEPLOYMENT_NAME: "phi3:3.8b-mini-4k-instruct-q4_K_M" # or gpt-4o-mini if you use openai
LLMAAJ_OPENAI_BASE_URL: "http://localhost:11434/v1" # ollama endpoint or https://api.openai.com/v1 if use use openai
LLMAAJ_OPENAI_API_KEY: "t"
LLMAAJ_OPENAI_EMBEDDING_DEPLOYMENT_NAME: "text-embedding-ada-002"

jobs:
evaluate:
runs-on: ubuntu-latest
container:
image: aminedjeghri/python3.11-nvm22.08:latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# - name: Install NVM
# shell: bash
# run : make install_nvm_node
- name: Install Python dependencies
shell: bash
run: |
make install-dev
- name: Install NPM dependencies
shell: bash
run: |
make install-npm-dependencies
- name: Download local models
shell: bash
run: |
make download-ollama-model
- name: Run tests
shell: bash
run: |
ollama serve &
make test
# - name: Run promptfoo evaluation
# shell: bash
# run: |
# source ${{ env.VENV_PATH }}/bin/activate
# make eval
31 changes: 31 additions & 0 deletions .github/workflows/deploy-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Deploy Github Pages'

#on:
# pull_request:
# push:

jobs:
# Build job
build:

# Deploy job
deploy:
# Add a dependency to the build job
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
15 changes: 15 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pre-commit

on:
pull_request:
push:

jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: pre-commit/[email protected]
192 changes: 192 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# 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/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# 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
.envd
.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/

# environment var
.env
*.secrets

# node
node_modules/

# github actions local
bin/act

#gitlab ci local
.gitlab-ci-local/
.gitlab-ci-local-env
.gitlab-ci-local.yml

# Windows specific files
*Zone.Identifier


.cache*

**/*tmp*.py
**/*temp*.py



src/evaluation/data/*
!src/evaluation/data/test_json.csv
!src/evaluation/data/test_simple.csv
Loading

0 comments on commit 573eb68

Please sign in to comment.