Skip to content

Commit c19fd1d

Browse files
Roopan-MicrosoftPrasanjeet-MicrosoftPrajwal-MicrosoftPradheep-MicrosoftPavan-Microsoft
authored
fix: Merging dev fixes into main (#333)
* Downgrade msal[broker] to 1.24.0b1 and azure-mgmt-resource to 23.1.0b2 * Downgrade azure-ai-ml package to version 1.17.1 to resolve package version conflicts (#283) * Upgrade azure-ai-ml package to compatible version * test: Research assistant backend unit test (#286) * Research assistant backend unit test * Research assistant backend unit test * Research assistant unit test pylint correction * pylint correction * research assistant .yml file * Update test_research_assistant.yml --------- Co-authored-by: Roopan-Microsoft <[email protected]> * fix: Research Assistant Deployment Issue - Prompt Flow version update (#287) * Prompt flow version update * Add files via upload * Add files via upload * Add files via upload --------- Co-authored-by: Roopan-Microsoft <[email protected]> * Implement Consistent Versioning and Tagging for Accelerator Images (#288) * Dev image version check * Revert "feat: Dev Image Version Check Test" * update history method changes (#295) * fix: Fixed Asset and retirement update query (#332) * updated Asset and retirement updated code * minor fix on meeting days * fixed test case * optimized query * fixed the UI issue in Chat history list section (#335) --------- Co-authored-by: Prasanjeet-Microsoft <[email protected]> Co-authored-by: Prajwal-Microsoft <[email protected]> Co-authored-by: Pradheep-Microsoft <[email protected]> Co-authored-by: Pavan-Microsoft <[email protected]> Co-authored-by: pradeepjha-microsoft <[email protected]> Co-authored-by: AjitPadhi-Microsoft <[email protected]> Co-authored-by: Mohan-Microsoft <[email protected]>
1 parent ac58687 commit c19fd1d

File tree

8 files changed

+735
-52
lines changed

8 files changed

+735
-52
lines changed

.github/workflows/build-docker.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ jobs:
4848
id: date
4949
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
5050

51+
- name: Determine Tag Name Based on Branch
52+
id: determine_tag
53+
run: echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT
54+
5155
- name: Build Docker Image and optionally push
5256
uses: docker/build-push-action@v6
5357
with:
5458
context: .
5559
file: ${{ inputs.dockerfile }}
5660
push: ${{ inputs.push }}
57-
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' || 'latest' }}
61+
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}
5862
tags: |
59-
${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
60-
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}
63+
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}
64+
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Unit Tests - Research Assistant
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
paths:
7+
- 'ResearchAssistant/**'
8+
pull_request:
9+
branches: [main, dev]
10+
types:
11+
- opened
12+
- ready_for_review
13+
- reopened
14+
- synchronize
15+
paths:
16+
- 'ResearchAssistant/**'
17+
18+
jobs:
19+
test_research_assistant:
20+
name: Research Assistant Tests
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.11"
30+
31+
- name: Install Backend Dependencies
32+
run: |
33+
cd ResearchAssistant/App
34+
python -m pip install --upgrade pip
35+
python -m pip install -r requirements.txt
36+
python -m pip install coverage pytest pytest-cov pytest-asyncio
37+
38+
- name: Run Backend Tests with Coverage
39+
run: |
40+
cd ResearchAssistant/App
41+
python -m pytest -vv --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing --cov-fail-under=80 --junitxml=coverage-junit.xml
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: research-assistant-coverage
45+
path: |
46+
ResearchAssistant/App/coverage.xml
47+
ResearchAssistant/App/coverage-junit.xml
48+
ResearchAssistant/App/htmlcov/

ClientAdvisor/App/app.py

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,35 +1588,72 @@ def get_users():
15881588
if len(rows) <= 6:
15891589
# update ClientMeetings,Assets,Retirement tables sample data to current date
15901590
cursor = conn.cursor()
1591-
cursor.execute(
1592-
"""select DATEDIFF(d,CAST(max(StartTime) AS Date),CAST(GETDATE() AS Date)) + 3 as ndays from ClientMeetings"""
1593-
)
1594-
rows = cursor.fetchall()
1595-
ndays = 0
1596-
for row in rows:
1597-
ndays = row["ndays"]
1598-
sql_stmt1 = f"UPDATE ClientMeetings SET StartTime = dateadd(day,{ndays},StartTime), EndTime = dateadd(day,{ndays},EndTime)"
1599-
cursor.execute(sql_stmt1)
1600-
conn.commit()
1601-
nmonths = int(ndays / 30)
1602-
if nmonths > 0:
1603-
sql_stmt1 = (
1604-
f"UPDATE Assets SET AssetDate = dateadd(MONTH,{nmonths},AssetDate)"
1591+
combined_stmt = """
1592+
WITH MaxDates AS (
1593+
SELECT
1594+
MAX(CAST(StartTime AS Date)) AS MaxClientMeetingDate,
1595+
MAX(AssetDate) AS MaxAssetDate,
1596+
MAX(StatusDate) AS MaxStatusDate
1597+
FROM
1598+
(SELECT StartTime, NULL AS AssetDate, NULL AS StatusDate FROM ClientMeetings
1599+
UNION ALL
1600+
SELECT NULL AS StartTime, AssetDate, NULL AS StatusDate FROM Assets
1601+
UNION ALL
1602+
SELECT NULL AS StartTime, NULL AS AssetDate, StatusDate FROM Retirement) AS Combined
1603+
),
1604+
Today AS (
1605+
SELECT GETDATE() AS TodayDate
1606+
),
1607+
DaysDifference AS (
1608+
SELECT
1609+
DATEDIFF(DAY, MaxClientMeetingDate, TodayDate) + 3 AS ClientMeetingDaysDifference,
1610+
DATEDIFF(DAY, MaxAssetDate, TodayDate) - 30 AS AssetDaysDifference,
1611+
DATEDIFF(DAY, MaxStatusDate, TodayDate) - 30 AS StatusDaysDifference
1612+
FROM MaxDates, Today
16051613
)
1606-
cursor.execute(sql_stmt1)
1614+
SELECT
1615+
ClientMeetingDaysDifference,
1616+
AssetDaysDifference / 30 AS AssetMonthsDifference,
1617+
StatusDaysDifference / 30 AS StatusMonthsDifference
1618+
FROM DaysDifference
1619+
"""
1620+
cursor.execute(combined_stmt)
1621+
date_diff_rows = cursor.fetchall()
1622+
1623+
client_days = (
1624+
date_diff_rows[0]["ClientMeetingDaysDifference"]
1625+
if date_diff_rows
1626+
else 0
1627+
)
1628+
asset_months = (
1629+
int(date_diff_rows[0]["AssetMonthsDifference"]) if date_diff_rows else 0
1630+
)
1631+
status_months = (
1632+
int(date_diff_rows[0]["StatusMonthsDifference"])
1633+
if date_diff_rows
1634+
else 0
1635+
)
1636+
1637+
# Update ClientMeetings
1638+
if client_days > 0:
1639+
client_update_stmt = f"UPDATE ClientMeetings SET StartTime = DATEADD(day, {client_days}, StartTime), EndTime = DATEADD(day, {client_days}, EndTime)"
1640+
cursor.execute(client_update_stmt)
16071641
conn.commit()
16081642

1609-
sql_stmt1 = f"UPDATE Retirement SET StatusDate = dateadd(MONTH,{nmonths},StatusDate)"
1610-
cursor.execute(sql_stmt1)
1643+
# Update Assets
1644+
if asset_months > 0:
1645+
asset_update_stmt = f"UPDATE Assets SET AssetDate = DATEADD(month, {asset_months}, AssetDate)"
1646+
cursor.execute(asset_update_stmt)
16111647
conn.commit()
16121648

1613-
cursor = conn.cursor()
1614-
cursor.execute(sql_stmt)
1615-
rows = cursor.fetchall()
1649+
# Update Retirement
1650+
if status_months > 0:
1651+
retire_update_stmt = f"UPDATE Retirement SET StatusDate = DATEADD(month, {status_months}, StatusDate)"
1652+
cursor.execute(retire_update_stmt)
1653+
conn.commit()
16161654

16171655
users = []
16181656
for row in rows:
1619-
# print(row)
16201657
user = {
16211658
"ClientId": row["ClientId"],
16221659
"ClientName": row["Client"],
@@ -1631,7 +1668,6 @@ def get_users():
16311668
"ClientSummary": row["ClientSummary"],
16321669
}
16331670
users.append(user)
1634-
# print(users)
16351671

16361672
return jsonify(users)
16371673

ClientAdvisor/App/frontend/src/api/api.ts

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -201,31 +201,47 @@ export const selectUser = async (options: ClientIdRequest): Promise<Response> =>
201201
return new Response(null, { status: 500, statusText: 'Internal Server Error' });
202202
}
203203
};
204-
204+
function isLastObjectNotEmpty(arr:any)
205+
{
206+
if (arr.length === 0) return false;
207+
// Handle empty array case
208+
const lastObj = arr[arr.length - 1];
209+
return Object.keys(lastObj).length > 0;
210+
}
205211
export const historyUpdate = async (messages: ChatMessage[], convId: string): Promise<Response> => {
206-
const response = await fetch('/history/update', {
207-
method: 'POST',
208-
body: JSON.stringify({
209-
conversation_id: convId,
210-
messages: messages
211-
}),
212-
headers: {
213-
'Content-Type': 'application/json'
214-
}
215-
})
216-
.then(async res => {
217-
return res
212+
if(isLastObjectNotEmpty(messages)){
213+
const response = await fetch('/history/update', {
214+
method: 'POST',
215+
body: JSON.stringify({
216+
conversation_id: convId,
217+
messages: messages
218+
}),
219+
headers: {
220+
'Content-Type': 'application/json'
221+
}
218222
})
219-
.catch(_err => {
220-
console.error('There was an issue fetching your data.')
223+
.then(async res => {
224+
return res
225+
})
226+
.catch(_err => {
227+
console.error('There was an issue fetching your data.')
228+
const errRes: Response = {
229+
...new Response(),
230+
ok: false,
231+
status: 500
232+
}
233+
return errRes
234+
})
235+
return response
236+
}
237+
else{
221238
const errRes: Response = {
222239
...new Response(),
223240
ok: false,
224241
status: 500
225242
}
226-
return errRes
227-
})
228-
return response
243+
return errRes
244+
}
229245
}
230246

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

426442
// const data = await response.text();
427443
// console.log('Response:', data);
428-
// };
444+
// };

ClientAdvisor/App/frontend/src/components/ChatHistory/ChatHistoryPanel.module.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.container {
2-
max-height: calc(100vh - 100px);
3-
width: 300px;
2+
height: calc(100vh - 100px);
3+
width: 305px;
44
}
55

66
.listContainer {
77
overflow: hidden auto;
8-
max-height: calc(90vh - 105px);
8+
height: calc(90vh - 230px);
99
}
1010

1111
.itemCell {
@@ -79,9 +79,9 @@
7979
}
8080

8181
@media screen and (-ms-high-contrast: active), (forced-colors: active) {
82-
.container{
83-
border: 2px solid WindowText;
84-
background-color: Window;
85-
color: WindowText;
82+
.container {
83+
border: 2px solid WindowText;
84+
background-color: Window;
85+
color: WindowText;
8686
}
87-
}
87+
}

ClientAdvisor/App/tests/test_app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ async def test_get_users_success(client):
208208
{
209209
"ClientId": 1,
210210
"ndays": 10,
211+
"ClientMeetingDaysDifference": 1,
212+
"AssetMonthsDifference": 1,
213+
"StatusMonthsDifference": 1,
214+
"DaysDifference": 1,
211215
"Client": "Client A",
212216
"Email": "[email protected]",
213217
"AssetValue": "1,000,000",

0 commit comments

Comments
 (0)