Skip to content

Commit

Permalink
Configure formatting and continuous integration (#28)
Browse files Browse the repository at this point in the history
* formatting for frontend

Signed-off-by: Swapnil Tripathi <[email protected]>

* add core formatting

Signed-off-by: Swapnil Tripathi <[email protected]>

* add linting to frontend

Signed-off-by: Swapnil Tripathi <[email protected]>

* add ci workflow

Signed-off-by: Swapnil Tripathi <[email protected]>

* add issue templates

Signed-off-by: Swapnil Tripathi <[email protected]>

* Add pull request templates and some minor refactors

Signed-off-by: Swapnil Tripathi <[email protected]>

* fix bug report template

Signed-off-by: Swapnil Tripathi <[email protected]>

* format frontend

Signed-off-by: Swapnil Tripathi <[email protected]>

* format the backend

Signed-off-by: Swapnil Tripathi <[email protected]>

---------

Signed-off-by: Swapnil Tripathi <[email protected]>
  • Loading branch information
swaptr authored Aug 14, 2024
1 parent 1a8da59 commit c6f4d70
Show file tree
Hide file tree
Showing 56 changed files with 2,167 additions and 1,420 deletions.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/0.feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Feature Request
description: "Suggest an idea for this project"
title: "[Feature]: <title>"
labels: ["enhancement"]
body:
- type: textarea
attributes:
label: Describe the feature
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: |
If applicable, add images/mockups/screenshots to help present your vision of the feature
description: Drag images into the text input below
validations:
required: false
- type: checkboxes
attributes:
label: Is there an existing feature request for this?
description: Please search to see if an issue already exists for the feature you are requesting.
options:
- label: I have searched the existing issues
required: true
59 changes: 59 additions & 0 deletions .github/ISSUE_TEMPLATE/1.bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Bug
description: File a bug/issue
title: "[BUG] <title>"
labels: ["bug", "needs triage"]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **OS**: Ubuntu 20.04
- **Node**: 13.14.0
- **Python**: 3.12.0
value: |
- OS:
- Node:
- Python:
render: markdown
validations:
required: false
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
50 changes: 50 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Pull Request Checklist

**Before submitting, make sure you've checked the following:**

- [ ] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [ ] **Description:** Provide a concise description of the changes made in this pull request.
- [ ] **Changelog:** Ensure a changelog entry is added below. In the changelog only keep relevant entries.
- [ ] **Documentation:** Have you updated relevant documentation, or other documentation sources?
- [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [ ] **Testing:** Have you written and run sufficient tests for validating the changes?
- [ ] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?

# Changelog Entry

## Description

Describe your change here

### Added

- [List any new features, functionalities, or additions]

### Changed

- [List any changes, updates, refactorings, or optimizations]

### Deprecated

- [List any deprecated functionality or features that have been removed]

### Removed

- [List any removed features, files, or functionalities]

### Fixed

- [List any fixes, corrections, or bug fixes]

### Security

- [List any new or updated security-related changes, including vulnerability fixes]

### Additional Information

- [Insert any additional context, notes, or explanations for the changes]
- [Reference any related issues, commits, or other relevant information]

### Screenshots or Videos

- [Attach any relevant screenshots or videos demonstrating the changes]
62 changes: 62 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

on:
push:
branches:
- main
- dev
pull_request:
branches:
- "**"

jobs:
format-frontend:
name: 'Format Frontend'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Dependencies
run: npm install

- name: Format Frontend
run: npm run format

- name: Post Formatting Check
run: git diff --exit-code

format-core:
name: 'Format Core'
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.12]

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Format Backend
run: |
cd src/core
sh scripts/format.sh
- name: Post Formatting Check
run: git diff --exit-code
5 changes: 4 additions & 1 deletion src/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from utils import load_yaml_file
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

# from routes.main import router as main_router
from routes.test import router as test_router

config_data = load_yaml_file("config.yaml")


def create_app() -> FastAPI:
# Create the FastAPI application
app = FastAPI()
Expand All @@ -26,4 +28,5 @@ def create_app() -> FastAPI:

return app

uvicorn.run(create_app,host=config_data["host"],port=config_data["port"])

uvicorn.run(create_app, host=config_data["host"], port=config_data["port"])
30 changes: 17 additions & 13 deletions src/core/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from session_history import get_session_history
from utils import load_yaml_file


def get_conversation():
config_data = load_yaml_file("config.yaml")

Expand All @@ -21,24 +22,27 @@ def get_conversation():

embeddings = embedding_function()

vectordb = Chroma(embedding_function=embeddings, persist_directory=config_data["persist_directory"])
vectordb = Chroma(
embedding_function=embeddings,
persist_directory=config_data["persist_directory"],
)

# Retrieve and generate using the relevant snippets of the blog.
retriever = vectordb.as_retriever()

# build huggingface pipeline for using zephyr-7b-beta
llm_pipeline = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
use_cache=True,
device_map="auto",
max_length=4096, # 4096
do_sample=True,
top_k=5,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
"text-generation",
model=model,
tokenizer=tokenizer,
use_cache=True,
device_map="auto",
max_length=4096, # 4096
do_sample=True,
top_k=5,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
)

# specify the llm
Expand Down Expand Up @@ -86,4 +90,4 @@ def get_conversation():
output_messages_key="answer",
)

return conversational_rag_chain
return conversational_rag_chain
13 changes: 6 additions & 7 deletions src/core/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
from utils import load_yaml_file
from langchain_huggingface import HuggingFaceEmbeddings


def embedding_function():
config_data = load_yaml_file("config.yaml")

# check if GPU is available, else use CPU
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model_name = config_data["embedding_model_name"]
model_kwargs = {'device': device}
encode_kwargs = {'normalize_embeddings': False}
model_kwargs = {"device": device}
encode_kwargs = {"normalize_embeddings": False}
embeddings = HuggingFaceEmbeddings(
model_name=model_name,
model_kwargs=model_kwargs,
encode_kwargs=encode_kwargs
model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs
)

return embeddings
return embeddings
Loading

0 comments on commit c6f4d70

Please sign in to comment.