Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
92664fd
Merge pull request #1 from kamal20122012/Restructure
kamal20122012 Oct 30, 2024
2ea44fd
Integrate Firebase
Aman-Pandey-afk Nov 3, 2024
5901fdd
Implemen Firebase Authentication
Aman-Pandey-afk Nov 4, 2024
aca7037
Revamp UI and responsive design
Aman-Pandey-afk Nov 6, 2024
61fe157
Revamp UI and responsive design
Aman-Pandey-afk Nov 6, 2024
fe77f5c
Make Response Service better
KamalUtla Nov 10, 2024
4b3bfeb
Add AiAgents, Dataset, LLMjudge and Evaluator class
KamalUtla Nov 11, 2024
b4b101c
small bug in LLmJudge init
KamalUtla Nov 11, 2024
f83d75e
Make Response Service better
Aman-Pandey-afk Nov 11, 2024
1734d13
Add Playground (#6)
Aman-Pandey-afk Nov 16, 2024
2db94c4
Update Dataset Handling
Aman-Pandey-afk Nov 17, 2024
db4a5a0
DB Update
BhaveshSonalkar Nov 17, 2024
8bda529
removed unused file
BhaveshSonalkar Nov 17, 2024
28cff96
minor refactor: renamed update_dataset_route to update_dataset
BhaveshSonalkar Nov 17, 2024
d58f8d7
renamed aiagent_routes.py to ai_agent_routes.py
BhaveshSonalkar Nov 17, 2024
b37cfdc
added nested serializeer
BhaveshSonalkar Nov 17, 2024
023ebcb
bug fix
BhaveshSonalkar Nov 17, 2024
84515e0
using marshmallow-mongoengine, fixed serializers
BhaveshSonalkar Nov 17, 2024
891f490
removed redundant index
BhaveshSonalkar Nov 17, 2024
3de4bfa
minor renamed: MULTITURN to MULTI_TURN
BhaveshSonalkar Nov 17, 2024
b4ba177
added add, update, remove for samples in dataset
BhaveshSonalkar Nov 17, 2024
7bf808e
Add or update the Azure App Service build and deployment workflow config
kamal20122012 Nov 17, 2024
eec2eae
added name field in AIAgent and Dataset
BhaveshSonalkar Nov 17, 2024
420b32d
removed aws creds check from yaml
BhaveshSonalkar Nov 17, 2024
0de4f91
moved requirements in root folder
BhaveshSonalkar Nov 19, 2024
228a7d5
adding firebase credentials
BhaveshSonalkar Nov 19, 2024
85e2025
import fix
BhaveshSonalkar Nov 20, 2024
7b5dd12
deleted firebase-credentials.json
BhaveshSonalkar Nov 20, 2024
0d2233f
fixed imports
BhaveshSonalkar Nov 20, 2024
6131040
renames app.py to run.py
BhaveshSonalkar Nov 20, 2024
2bc2d9b
modified the data structure to allow for nested data also added base-…
BhaveshSonalkar Feb 1, 2025
4fb0f10
added fixes in the code
BhaveshSonalkar Feb 1, 2025
b585ed9
added more fixes
BhaveshSonalkar Feb 1, 2025
125a21e
added evaluation service and added lint ignore to f"" with no placeho…
BhaveshSonalkar Feb 1, 2025
d37a9d8
added evaluation routes
BhaveshSonalkar Feb 1, 2025
113f49e
using id instead of index in variant
BhaveshSonalkar Feb 1, 2025
257c4bd
moved from blueprints to viewsets
BhaveshSonalkar Feb 1, 2025
474fff0
eliminated the use of ai_agent_services
BhaveshSonalkar Feb 1, 2025
2b06f02
minor change
BhaveshSonalkar Feb 1, 2025
d65de04
made improvements to evaluator service
BhaveshSonalkar Feb 1, 2025
cbca4a9
bug fixes
BhaveshSonalkar Feb 1, 2025
932c745
fixed routes
BhaveshSonalkar Feb 1, 2025
8049e79
fixed url paths
BhaveshSonalkar Feb 2, 2025
8a660c9
fix
BhaveshSonalkar Feb 2, 2025
e641f82
projects api tested and finalized
BhaveshSonalkar Feb 2, 2025
977cb5a
minor rename
BhaveshSonalkar Feb 2, 2025
41bd9bf
tested ai agents views
BhaveshSonalkar Feb 2, 2025
84dca9e
tested ai agent variant routes
BhaveshSonalkar Feb 2, 2025
86c3f7e
modified dataset view to be more restful
BhaveshSonalkar Feb 2, 2025
5a45e52
created api_views folder instead of api
BhaveshSonalkar Feb 2, 2025
b09ed3d
modified evaluation_view to be more restful
BhaveshSonalkar Feb 2, 2025
93627d0
llm evaluation tested
BhaveshSonalkar Feb 2, 2025
8138cf9
minor rename
BhaveshSonalkar Feb 2, 2025
4c29910
minor changes
BhaveshSonalkar Feb 2, 2025
9e32e52
added embedding similarity metric
BhaveshSonalkar Feb 2, 2025
6c34ca9
added embedding service
BhaveshSonalkar Feb 2, 2025
af0137f
minor change
BhaveshSonalkar Feb 2, 2025
2f6a213
added embedding service with client
BhaveshSonalkar Feb 2, 2025
89a5839
more modular embedding service
BhaveshSonalkar Feb 2, 2025
0afa3f4
default addition
BhaveshSonalkar Feb 2, 2025
bd5acaf
import fixes
BhaveshSonalkar Feb 2, 2025
9e7480b
fixed embedding evaluation service
BhaveshSonalkar Feb 2, 2025
6b1ccfc
minor fix
BhaveshSonalkar Feb 2, 2025
6c54f1a
Added Readme
BhaveshSonalkar Feb 2, 2025
94e329c
updated readme
BhaveshSonalkar Feb 2, 2025
350d4a2
updated readme
BhaveshSonalkar Feb 2, 2025
f42184a
fixes in streaming response service
BhaveshSonalkar Feb 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
extend-ignore = E203, E266, E501, W503, F403, F401, F841, F405, F541
max-line-length = 120
78 changes: 78 additions & 0 deletions .github/workflows/master_proback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions

name: Build and deploy Python app to Azure Web App - proback

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Install dependencies
run: pip install -r requirements.txt

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: python-app
path: |
release.zip
!venv/

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: python-app

- name: Unzip artifact for deployment
run: unzip release.zip


- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_03FB85159B9A4E78AACF5C9E49520FA7 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_CDBEEAED51A249279383A6E8687EC9C2 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_8376CC7B1D6F40DAACC0EE4E277694F7 }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'proback'
slot-name: 'Production'

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ htmlcov/
.tox/
docs/_build/
*.json
firebase-credentials.json
firebase-credentials.json
*.log
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
files: ^server/.*\.py$
repos:
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: ["--line-length=120"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8

default_stages: [pre-commit, pre-push]
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ProBack Backend

## Installation

### Prerequisites

- Python 3.12
- MongoDB Instance
- Firebase Project with service account credentials

### Steps

1. **Clone the Repository**

```bash
git clone <repo_url>
cd proback/server
```

2. **Create Virtual Environment**

```bash
python -m venv venv
source venv/bin/activate
```

3. **Install Dependencies**

```bash
pip install -r requirements.txt
```

4. **Configure Environment Variables**

Create a `.env` file in the `server` directory with the following:

```env
MONGO_URI=your_mongodb_uri
SECRET_KEY=your_secret_key
CLAUDE_API_KEY=your_claude_api_key
OPENAI_API_KEY=your_openai_api_key
```

5. **Firebase Setup**

Place your `firebase-credentials.json` in the project root as specified in `config.py`.

## Configuration

The backend configuration is managed through the `Config` class in `server/app/config.py`. It loads environment variables and sets default values for various settings.

### CORS

Configure allowed origins in the `CORS_ORIGINS` list within `config.py`.


### Setup Pre-commit

1. change directory to server and do `pip install -r requirements.txt`
2. now run `pre-commit install` to install precommit hooks
3. now you can run `pre-commit run --all-files` to run precommit hooks on all files if you want to run on specific file then run `pre-commit run <file_name>`
Binary file added requirements.txt
Binary file not shown.
Binary file added server/.DS_Store
Binary file not shown.
File renamed without changes.
Binary file added server/app/.DS_Store
Binary file not shown.
72 changes: 51 additions & 21 deletions server/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,59 @@
from flask import Flask
import logging

import certifi
import mongoengine
from flask import Blueprint, Flask
from flask_cors import CORS
from .config import Config
from .api.auth_routes import auth_bp

from .api_views.ai_agent_variant_view import agent_variant_bp
from .api_views.ai_agent_view import ai_agent_bp
from .api_views.auth_view import auth_bp
from .api_views.config_view import config_bp
from .api_views.dataset_view import dataset_bp
from .api_views.evaluation_view import evaluation_bp
from .api_views.main_view import main_bp
from .api_views.project_view import project_bp
from .config import Config, Logging

# Initialize logging once
Logging.initialize(log_level=logging.INFO, log_file="application.log")


def register_api_blueprints(app):
api_bp = Blueprint("api", __name__, url_prefix="/api")
api_bp.register_blueprint(config_bp)
api_bp.register_blueprint(auth_bp)
api_bp.register_blueprint(project_bp)
api_bp.register_blueprint(evaluation_bp)
api_bp.register_blueprint(dataset_bp)
api_bp.register_blueprint(ai_agent_bp)
api_bp.register_blueprint(agent_variant_bp)
app.register_blueprint(api_bp)
app.register_blueprint(main_bp)


def create_app(config_class=Config):
app = Flask(__name__,
static_folder='../../src/static', # Points to frontend files
template_folder='../../src/templates') # Points to frontend files

# Load config
"""
Create a Flask app with the given configuration.
"""
app = Flask(__name__, static_folder="../../src/static", template_folder="../../src/templates")

# mongoengine
mongoengine.connect(
host=config_class.MONGO_URI,
ssl=True,
tlscafile=certifi.where(),
)

# config
app.config.from_object(config_class)

# Initialize CORS
CORS(app)

# Register blueprints
from .api.character_routes import character_bp
from .api.dataset_routes import dataset_bp
from .api.evaluation_routes import evaluation_bp
from .api.main import main_bp
# make url_map not strict
app.url_map.strict_slashes = False

app.register_blueprint(main_bp)
app.register_blueprint(character_bp, url_prefix='/api')
app.register_blueprint(dataset_bp, url_prefix='/api')
app.register_blueprint(evaluation_bp, url_prefix='/api')
app.register_blueprint(auth_bp, url_prefix='/api')
# cors
CORS(app)

# register api blueprints
register_api_blueprints(app)
return app
34 changes: 0 additions & 34 deletions server/app/api/auth_routes.py

This file was deleted.

54 changes: 0 additions & 54 deletions server/app/api/character_routes.py

This file was deleted.

Loading