Skip to content

Commit

Permalink
Merge branch 'main' into dependabotchanges
Browse files Browse the repository at this point in the history
  • Loading branch information
Roopan-Microsoft committed Feb 21, 2025
2 parents f3370b8 + 9de1661 commit 74f41a7
Show file tree
Hide file tree
Showing 35 changed files with 761 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CAdeploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI-Validate Deployment-Client Advisor
name: Validate Deployment - Client Advisor

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/RAdeploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI-Validate Deployment-Research Assistant
name: Validate Deployment - Researcher

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
paths:
- 'ResearchAssistant/**'
schedule:
- cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT
- cron: '0 7,19 * * *' # Runs at 7:00 AM and 7:00 PM GMT

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-clientadvisor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build ClientAdvisor Docker Images
name: Build Docker and Optional Push - Client Advisor

on:
push:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ jobs:
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Determine Tag Name Based on Branch
id: determine_tag
run: echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT

- name: Build Docker Image and optionally push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ inputs.dockerfile }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || 'latest' }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}
tags: |
${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo'|| github.ref_name == 'dependabotchanges' && 'dependabotchanges' || 'latest' }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
2 changes: 1 addition & 1 deletion .github/workflows/build-researchassistant.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build ResearchAssistant Docker Images
name: Build Docker and Optional Push - Researcher

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-title-checker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "pr-title-checker"
name: "PR Title Checker"

on:
pull_request_target:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pylint
name: PyLint

on: [push]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale-bot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Close stale issues and PRs'
name: 'Stale Bot'
on:
schedule:
- cron: '30 1 * * *'
Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/sync-branches.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test_client_advisor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit Tests - Client Advisor
name: Test Workflow with Coverage - Client Advisor

on:
push:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/test_research_assistant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test Workflow with Coverage - Researcher

on:
push:
branches: [main, dev]
paths:
- 'ResearchAssistant/**'
pull_request:
branches: [main, dev]
types:
- opened
- ready_for_review
- reopened
- synchronize
paths:
- 'ResearchAssistant/**'

jobs:
test_research_assistant:
name: Research Assistant Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Backend Dependencies
run: |
cd ResearchAssistant/App
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install coverage pytest pytest-cov pytest-asyncio
- name: Run Backend Tests with Coverage
run: |
cd ResearchAssistant/App
python -m pytest -vv --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing --cov-fail-under=80 --junitxml=coverage-junit.xml
- uses: actions/upload-artifact@v4
with:
name: research-assistant-coverage
path: |
ResearchAssistant/App/coverage.xml
ResearchAssistant/App/coverage-junit.xml
ResearchAssistant/App/htmlcov/
80 changes: 58 additions & 22 deletions ClientAdvisor/App/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,35 +1588,72 @@ def get_users():
if len(rows) <= 6:
# update ClientMeetings,Assets,Retirement tables sample data to current date
cursor = conn.cursor()
cursor.execute(
"""select DATEDIFF(d,CAST(max(StartTime) AS Date),CAST(GETDATE() AS Date)) + 3 as ndays from ClientMeetings"""
)
rows = cursor.fetchall()
ndays = 0
for row in rows:
ndays = row["ndays"]
sql_stmt1 = f"UPDATE ClientMeetings SET StartTime = dateadd(day,{ndays},StartTime), EndTime = dateadd(day,{ndays},EndTime)"
cursor.execute(sql_stmt1)
conn.commit()
nmonths = int(ndays / 30)
if nmonths > 0:
sql_stmt1 = (
f"UPDATE Assets SET AssetDate = dateadd(MONTH,{nmonths},AssetDate)"
combined_stmt = """
WITH MaxDates AS (
SELECT
MAX(CAST(StartTime AS Date)) AS MaxClientMeetingDate,
MAX(AssetDate) AS MaxAssetDate,
MAX(StatusDate) AS MaxStatusDate
FROM
(SELECT StartTime, NULL AS AssetDate, NULL AS StatusDate FROM ClientMeetings
UNION ALL
SELECT NULL AS StartTime, AssetDate, NULL AS StatusDate FROM Assets
UNION ALL
SELECT NULL AS StartTime, NULL AS AssetDate, StatusDate FROM Retirement) AS Combined
),
Today AS (
SELECT GETDATE() AS TodayDate
),
DaysDifference AS (
SELECT
DATEDIFF(DAY, MaxClientMeetingDate, TodayDate) + 3 AS ClientMeetingDaysDifference,
DATEDIFF(DAY, MaxAssetDate, TodayDate) - 30 AS AssetDaysDifference,
DATEDIFF(DAY, MaxStatusDate, TodayDate) - 30 AS StatusDaysDifference
FROM MaxDates, Today
)
cursor.execute(sql_stmt1)
SELECT
ClientMeetingDaysDifference,
AssetDaysDifference / 30 AS AssetMonthsDifference,
StatusDaysDifference / 30 AS StatusMonthsDifference
FROM DaysDifference
"""
cursor.execute(combined_stmt)
date_diff_rows = cursor.fetchall()

client_days = (
date_diff_rows[0]["ClientMeetingDaysDifference"]
if date_diff_rows
else 0
)
asset_months = (
int(date_diff_rows[0]["AssetMonthsDifference"]) if date_diff_rows else 0
)
status_months = (
int(date_diff_rows[0]["StatusMonthsDifference"])
if date_diff_rows
else 0
)

# Update ClientMeetings
if client_days > 0:
client_update_stmt = f"UPDATE ClientMeetings SET StartTime = DATEADD(day, {client_days}, StartTime), EndTime = DATEADD(day, {client_days}, EndTime)"
cursor.execute(client_update_stmt)
conn.commit()

sql_stmt1 = f"UPDATE Retirement SET StatusDate = dateadd(MONTH,{nmonths},StatusDate)"
cursor.execute(sql_stmt1)
# Update Assets
if asset_months > 0:
asset_update_stmt = f"UPDATE Assets SET AssetDate = DATEADD(month, {asset_months}, AssetDate)"
cursor.execute(asset_update_stmt)
conn.commit()

cursor = conn.cursor()
cursor.execute(sql_stmt)
rows = cursor.fetchall()
# Update Retirement
if status_months > 0:
retire_update_stmt = f"UPDATE Retirement SET StatusDate = DATEADD(month, {status_months}, StatusDate)"
cursor.execute(retire_update_stmt)
conn.commit()

users = []
for row in rows:
# print(row)
user = {
"ClientId": row["ClientId"],
"ClientName": row["Client"],
Expand All @@ -1631,7 +1668,6 @@ def get_users():
"ClientSummary": row["ClientSummary"],
}
users.append(user)
# print(users)

return jsonify(users)

Expand Down
54 changes: 35 additions & 19 deletions ClientAdvisor/App/frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,31 +201,47 @@ export const selectUser = async (options: ClientIdRequest): Promise<Response> =>
return new Response(null, { status: 500, statusText: 'Internal Server Error' });
}
};

function isLastObjectNotEmpty(arr:any)
{
if (arr.length === 0) return false;
// Handle empty array case
const lastObj = arr[arr.length - 1];
return Object.keys(lastObj).length > 0;
}
export const historyUpdate = async (messages: ChatMessage[], convId: string): Promise<Response> => {
const response = await fetch('/history/update', {
method: 'POST',
body: JSON.stringify({
conversation_id: convId,
messages: messages
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(async res => {
return res
if(isLastObjectNotEmpty(messages)){
const response = await fetch('/history/update', {
method: 'POST',
body: JSON.stringify({
conversation_id: convId,
messages: messages
}),
headers: {
'Content-Type': 'application/json'
}
})
.catch(_err => {
console.error('There was an issue fetching your data.')
.then(async res => {
return res
})
.catch(_err => {
console.error('There was an issue fetching your data.')
const errRes: Response = {
...new Response(),
ok: false,
status: 500
}
return errRes
})
return response
}
else{
const errRes: Response = {
...new Response(),
ok: false,
status: 500
}
return errRes
})
return response
return errRes
}
}

export const historyDelete = async (convId: string): Promise<Response> => {
Expand Down Expand Up @@ -425,4 +441,4 @@ export const historyMessageFeedback = async (messageId: string, feedback: string

// const data = await response.text();
// console.log('Response:', data);
// };
// };
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.container {
max-height: calc(100vh - 100px);
width: 300px;
height: calc(100vh - 100px);
width: 305px;
}

.listContainer {
overflow: hidden auto;
max-height: calc(90vh - 105px);
height: calc(90vh - 230px);
}

.itemCell {
Expand Down Expand Up @@ -79,9 +79,9 @@
}

@media screen and (-ms-high-contrast: active), (forced-colors: active) {
.container{
border: 2px solid WindowText;
background-color: Window;
color: WindowText;
.container {
border: 2px solid WindowText;
background-color: Window;
color: WindowText;
}
}
}
4 changes: 4 additions & 0 deletions ClientAdvisor/App/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ async def test_get_users_success(client):
{
"ClientId": 1,
"ndays": 10,
"ClientMeetingDaysDifference": 1,
"AssetMonthsDifference": 1,
"StatusMonthsDifference": 1,
"DaysDifference": 1,
"Client": "Client A",
"Email": "[email protected]",
"AssetValue": "1,000,000",
Expand Down
Binary file modified ClientAdvisor/Deployment/images/readMe/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ClientAdvisor/Deployment/images/readMe/keyfeatures.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ClientAdvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For additional training and support, please see:
### **How to install/deploy**

1. Please check the link [Azure Products by Region](
https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?products=all&regions=all) and choose a region where Azure AI Search, Semantic Ranker, Azure OpenAI Service, and Azure AI Studio are available.
https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?products=all&regions=all) and choose a region where Azure AI Search, Semantic Ranker, Azure OpenAI Service, and Azure AI Foundry are available.

2. Click the following deployment button to create the required resources for this accelerator in your Azure Subscription.

Expand Down
Loading

0 comments on commit 74f41a7

Please sign in to comment.