Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions .github/workflows/changelog_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if __name__ == "__main__":
with open("../../CHANGELOG.md") as f:
temp = f.readlines()

# divide the file into four categories
commit, name, date, msg = [], [], [], []

# regex is <commit>\t<name>\t<date>\t<msg>
for line in temp:
line = line.split('\t')
commit.append(line[0])
name.append(line[1])
date.append(line[2])
msg.append(line[3])

# first detect the number of unique year-month combo
date_year_month = [x[:7] for x in date]
unique = sorted(list(set(date_year_month)), reverse=True)

# based on this write from the reverse order
final_lines = []

for year_month in unique:
# first write the header
final_lines.append(f"# {year_month}\n\n")

# loop through and stop when the year_month is lesser
for idx in range(len(date)):
if date[idx][:7] == year_month:
l = f"- {commit[idx]} {name[idx]} {date[idx]} {msg[idx]}"
final_lines.append(l)
final_lines.append("\n")

with open('../../CHANGELOG.md', 'w') as f:
for l in final_lines:
f.write(l)
41 changes: 41 additions & 0 deletions .github/workflows/ci-changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update Changelog

on:
workflow_dispatch:

jobs:
updateChangeLog:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

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

- name: Create Changelog file
run: |
make changelog

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_PAT }}
commit-message: Update report
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
signoff: true
base: master
branch: update-chglog
delete-branch: true
title: Changelog Update
body: |
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
docs
assignees: luarss
reviewers: luarss
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
cp ${{ secrets.PATH_TO_GOOGLE_APPLICATION_CREDENTIALS }} evaluation/auto_evaluation/src
- name: Build Docker image
run: |
make docker
make docker-up
sleep 900 # TODO: Remove this after docker-compose healthcheck timeout restored fixed.
- name: Run LLM CI
working-directory: evaluation
Expand All @@ -48,4 +48,4 @@ jobs:
- name: Teardown
if: always()
run: |
docker compose down --remove-orphans
make docker-down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ check:
@. ./backend/.venv/bin/activate && \
pre-commit run --all-files

docker:
docker-up:
@docker compose up --build --wait

docker-down:
@docker compose down --remove-orphans

changelog:
@git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=short --since="2024-06-01" > CHANGELOG.md
@cd .github/workflows && python changelog_report.py
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ services:
# timeout: 10s
# retries: 5
# start_period: 30 s # todo: make sure that this healthcheck starts after the API in the backend is ready.

frontend:
build:
context: ./frontend
container_name: "orassistant-frontend"
ports:
- "8501:8501"
networks:
- orassistant-network

# health-checker:
# build: ./common
Expand Down
18 changes: 18 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.12.3-slim

WORKDIR /ORAssistant-frontend

COPY ./requirements.txt /ORAssistant-frontend/requirements.txt
COPY ./requirements-test.txt /ORAssistant-frontend/requirements-test.txt
COPY ./pyproject.toml /ORAssistant-frontend/pyproject.toml

RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir -r requirements-test.txt && \
pip install --no-cache-dir -e .

COPY streamlit_app.py .
COPY ./utils ./utils
COPY ./assets ./assets

CMD ["streamlit", "run", "streamlit_app.py"]
7 changes: 4 additions & 3 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FrontEnd For Streamlit
# Frontend For Streamlit

This Folder contains the frontend code for the OR Assistant using Streamlit. Follow the instructions below to set up the environment, run the application, and perform testing using a mock API.
This folder contains the frontend code for the OR Assistant using Streamlit. Follow the instructions below to set up the environment, run the application, and perform testing using a mock API.

## Preparing the Environment Variables

Expand Down Expand Up @@ -39,6 +39,7 @@ To collect feedback, you need to set up a Google Sheet and configure the necessa
```
4. **Set the Current Version for Feedback Evaluation:**
- Add the current version of the feedback evaluation to the environment variables.
- If unset, this defaults to the commit hash of `master`.

```plaintext
RAG_VERSION=<current-version>
Expand Down Expand Up @@ -73,4 +74,4 @@ This will start a mock API server that simulates responses for testing purposes.

## License

This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the [LICENSE](../../LICENSE) file for details.
This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the [LICENSE](../LICENSE) file for details.
2 changes: 1 addition & 1 deletion frontend/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def main() -> None:
base_url, endpoints = fetch_endpoints()

selected_endpoint = st.selectbox(
"Select preferred architecture",
"Select preferred endpoint",
options=endpoints,
index=0,
format_func=lambda x: x.split("/")[-1].capitalize(),
Expand Down
26 changes: 22 additions & 4 deletions frontend/utils/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ def submit_feedback_to_google_sheet(
"The FEEDBACK_SHEET_ID environment variable is not set or is empty."
)

if not os.getenv("RAG_VERSION"):
raise ValueError("The RAG_VERSION environment variable is not set or is empty.")

service_account_file = os.getenv("GOOGLE_CREDENTIALS_JSON")
scope = [
"https://spreadsheets.google.com/feeds",
Expand Down Expand Up @@ -186,10 +183,31 @@ def show_feedback_form(
sources=sources,
context=context,
issue=feedback,
version=os.getenv("RAG_VERSION", "N/A"),
version=os.getenv("RAG_VERSION", get_git_commit_hash()),
)

st.session_state.submitted = True

if st.session_state.submitted:
st.sidebar.success("Thank you for your feedback!")


def get_git_commit_hash() -> str:
"""
Get the latest commit hash from the Git repository.

Returns:
- str: The latest commit hash.
"""
import subprocess

try:
commit_hash = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
.strip()
.decode("utf-8")
)
except subprocess.CalledProcessError:
commit_hash = "N/A"

return commit_hash