Skip to content

Commit 3bf5016

Browse files
Roopan-MicrosoftPrashant-MicrosoftKiran-Siluveru-MicrosoftMohan-MicrosoftHarmanpreet-Microsoft
authored
fix: UI Enhancements, Error handling, Docker integration and other bug fixes (microsoft#52)
* fix: ui changes (microsoft#1) * fix: in progress status color after fetch task details (microsoft#5) * cancel notification message updated (microsoft#7) * Update task.js (microsoft#9) * Stages overflow issue fix (microsoft#10) * fix: added space to the agent (microsoft#13) * Approve reject buttons titles disabling buttons and (microsoft#15) * Fix: UX becomes damaged when chat outputs sample code for a task (microsoft#14) * task page UI updates * UI updated code for task * Task page UI updated code * status section UI update in task page * Added custom event (microsoft#24) * feat: added custom event * Logs updated * modify code * added exception logs * added exception logs for cosmos memory --------- Co-authored-by: Roopan P M <[email protected]> * fix: task with zero stages cannot show the page, spins forever and rai test prompt (microsoft#41) * Updated the workflow for build and push docker * updated the repo name * Update requirements.txt * Update requirements.txt * Update requirements.txt * feat: Integrated application insights instrumentation key into the bicep file (microsoft#42) * feat: Integrated application insights instrumentation key into bicep files * added application insights instrumentation key into env and readme file * updated json file * upgraded json file * Update docker-build-and-push.yml * Update docker-build-and-push.yml * Update docker-build-and-push.yml * Update docker-build-and-push.yml * Update docker-build-and-push.yml * Update docker-build-and-push.yml * pyLint issues fixed * lint issues fixed --------- Co-authored-by: Roopan-Microsoft <[email protected]> Co-authored-by: Roopan P M <[email protected]> * Update test.yml (microsoft#43) * Disabling Text Area functionality (microsoft#47) * fix: Usability and Alignments changes (microsoft#48) * Name update and padding removed * fix home page padding and cards height * remove gap in tasks section * Update docker-build-and-push.yml to debug * Update docker-build-and-push.yml * Update docker-build-and-push.yml to take the correct event name * Update docker-build-and-push.yml * fix: text area background color (microsoft#50) * fix: text area background color * Cursor hover style and Light dark color updated --------- Co-authored-by: Prashant-Microsoft <[email protected]> Co-authored-by: Kiran-Siluveru-Microsoft <[email protected]> Co-authored-by: Mohan-Microsoft <[email protected]> Co-authored-by: Harmanpreet-Microsoft <[email protected]>
1 parent fcf538e commit 3bf5016

28 files changed

+578
-210
lines changed

.github/workflows/docker-build-and-push.yml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,13 @@ jobs:
3232
uses: docker/setup-buildx-action@v1
3333

3434
- name: Log in to Azure Container Registry
35-
if: ${{ github.ref_name == 'main' }}
35+
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix') }}
3636
uses: azure/docker-login@v2
3737
with:
3838
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
3939
username: ${{ secrets.ACR_USERNAME }}
4040
password: ${{ secrets.ACR_PASSWORD }}
4141

42-
- name: Log in to Azure Container Registry (Dev/Demo)
43-
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
44-
uses: azure/docker-login@v2
45-
with:
46-
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
47-
username: ${{ secrets.ACR_DEV_USERNAME }}
48-
password: ${{ secrets.ACR_DEV_PASSWORD }}
49-
5042
- name: Set Docker image tag
5143
run: |
5244
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
@@ -57,27 +49,27 @@ jobs:
5749
echo "TAG=demo" >> $GITHUB_ENV
5850
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
5951
echo "TAG=hotfix" >> $GITHUB_ENV
52+
else
53+
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
6054
fi
61-
- name: Build and push Docker images
62-
if: ${{ github.ref_name == 'main' }}
63-
run: |
64-
cd src/backend
65-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \
66-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \
67-
echo "Backend image built and pushed successfully."
68-
cd ../frontend
69-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \
70-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \
71-
echo "Frontend image built and pushed successfully."
72-
- name: Build and push Docker images (Dev/Demo/hotfix)
73-
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
55+
56+
- name: Build and push Docker images optionally
7457
run: |
7558
cd src/backend
76-
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \
77-
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \
78-
echo "Dev/Demo/Hotfix Backend image built and pushed successfully."
59+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} -f Dockerfile . && \
60+
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
61+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
62+
echo "Backend image built and pushed successfully."
63+
else
64+
echo "Skipping Docker push for backend with tag: ${{ env.TAG }}"
65+
fi
7966
cd ../frontend
80-
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \
81-
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \
82-
echo "Dev/Demo/Hotfix Frontend image built and pushed successfully."
67+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} -f Dockerfile . && \
68+
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
69+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
70+
echo "Frontend image built and pushed successfully."
71+
else
72+
echo "Skipping Docker push for frontend with tag: ${{ env.TAG }}"
73+
fi
74+
8375

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
python -m pip install --upgrade pip
3939
pip install -r src/backend/requirements.txt
4040
pip install pytest-cov
41+
pip install pytest-asyncio
4142
4243
- name: Check if test files exist
4344
id: check_tests

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ To add your newly created backend image:
177177
name: 'FRONTEND_SITE_NAME'
178178
value: 'https://<website Name>.azurewebsites.net'
179179

180+
name: 'APPLICATIONINSIGHTS_INSTRUMENTATION_KEY'
181+
value: <Application Insights Instrumentation Key>
182+
180183
- Click 'Save' and deploy your new revision
181184

182185
To add the new container to your website run the following:

deploy/macae-continer-oc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.32.4.45862",
9-
"templateHash": "17567587246932458853"
9+
"templateHash": "13282901028774763433"
1010
}
1111
},
1212
"parameters": {
@@ -366,13 +366,18 @@
366366
{
367367
"name": "FRONTEND_SITE_NAME",
368368
"value": "[format('https://{0}.azurewebsites.net', format(variables('uniqueNameFormat'), 'frontend'))]"
369+
},
370+
{
371+
"name": "APPLICATIONINSIGHTS_INSTRUMENTATION_KEY",
372+
"value": "[reference('appInsights').ConnectionString]"
369373
}
370374
]
371375
}
372376
]
373377
}
374378
},
375379
"dependsOn": [
380+
"appInsights",
376381
"cosmos::autogenDb",
377382
"containerAppEnv",
378383
"cosmos",

deploy/macae-continer.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
279279
name: 'FRONTEND_SITE_NAME'
280280
value: 'https://${format(uniqueNameFormat, 'frontend')}.azurewebsites.net'
281281
}
282+
{
283+
name: 'APPLICATIONINSIGHTS_INSTRUMENTATION_KEY'
284+
value: appInsights.properties.ConnectionString
285+
}
282286
]
283287
}
284288
]

src/backend/.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ COSMOSDB_CONTAINER=memory
55
AZURE_OPENAI_ENDPOINT=
66
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
77
AZURE_OPENAI_API_VERSION=2024-08-01-preview
8+
APPLICATIONINSIGHTS_INSTRUMENTATION_KEY=
89

910
BACKEND_API_URL='http://localhost:8000'
1011
FRONTEND_SITE_NAME='http://127.0.0.1:3000'

src/backend/agents/agentutils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import json
22

3-
from autogen_core.components.models import (AssistantMessage,
4-
AzureOpenAIChatCompletionClient)
3+
from autogen_core.components.models import (
4+
AssistantMessage,
5+
AzureOpenAIChatCompletionClient,
6+
)
57
from pydantic import BaseModel
68

79
from context.cosmos_memory import CosmosBufferedChatCompletionContext
8-
from models.messages import InputTask, PlanStatus, Step, StepStatus
10+
from models.messages import Step
911

1012
common_agent_system_message = "If you do not have the information for the arguments of the function you need to call, do not call the function. Instead, respond back to the user requesting further information. You must not hallucinate or invent any of the information used as arguments in the function. For example, if you need to call a function that requires a delivery address, you must not generate 123 Example St. You must skip calling functions and return a clarification message along the lines of: Sorry, I'm missing some information I need to help you with that. Could you please provide the delivery address so I can do that for you?"
1113

@@ -27,7 +29,7 @@ class FSMStateAndTransition(BaseModel):
2729
identifiedTargetState: str
2830
identifiedTargetTransition: str
2931

30-
cosmos = CosmosBufferedChatCompletionContext(session_id or "",user_id)
32+
cosmos = CosmosBufferedChatCompletionContext(session_id or "", user_id)
3133
combined_LLM_messages = [
3234
AssistantMessage(content=step.action, source="GroupChatManager")
3335
]

src/backend/agents/base_agent.py

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@
33

44
from autogen_core.base import AgentId, MessageContext
55
from autogen_core.components import RoutedAgent, message_handler
6-
from autogen_core.components.models import (AssistantMessage,
7-
AzureOpenAIChatCompletionClient,
8-
LLMMessage, SystemMessage,
9-
UserMessage)
6+
from autogen_core.components.models import (
7+
AssistantMessage,
8+
AzureOpenAIChatCompletionClient,
9+
LLMMessage,
10+
SystemMessage,
11+
UserMessage,
12+
)
1013
from autogen_core.components.tool_agent import tool_agent_caller_loop
1114
from autogen_core.components.tools import Tool
1215

1316
from context.cosmos_memory import CosmosBufferedChatCompletionContext
14-
from models.messages import (ActionRequest, ActionResponse,
15-
AgentMessage, Step, StepStatus)
17+
from models.messages import (
18+
ActionRequest,
19+
ActionResponse,
20+
AgentMessage,
21+
Step,
22+
StepStatus,
23+
)
24+
from azure.monitor.events.extension import track_event
25+
1626

1727
class BaseAgent(RoutedAgent):
1828
def __init__(
@@ -94,15 +104,54 @@ async def handle_action_request(
94104
step_id=message.step_id,
95105
)
96106
)
107+
108+
track_event(
109+
"Base agent - Added into the cosmos",
110+
{
111+
"session_id": message.session_id,
112+
"user_id": self._user_id,
113+
"plan_id": message.plan_id,
114+
"content": f"{result}",
115+
"source": self._agent_name,
116+
"step_id": message.step_id,
117+
},
118+
)
119+
97120
except Exception as e:
98-
print(f"Error during LLM call: {e}")
121+
logging.exception(f"Error during LLM call: {e}")
122+
track_event(
123+
"Base agent - Error during llm call, captured into the cosmos",
124+
{
125+
"session_id": message.session_id,
126+
"user_id": self._user_id,
127+
"plan_id": message.plan_id,
128+
"content": f"{e}",
129+
"source": self._agent_name,
130+
"step_id": message.step_id,
131+
},
132+
)
133+
99134
return
100135
print(f"Task completed: {result}")
101136

102137
step.status = StepStatus.completed
103138
step.agent_reply = result
104139
await self._model_context.update_step(step)
105140

141+
track_event(
142+
"Base agent - Updated step and updated into the cosmos",
143+
{
144+
"status": StepStatus.completed,
145+
"session_id": message.session_id,
146+
"agent_reply": f"{result}",
147+
"user_id": self._user_id,
148+
"plan_id": message.plan_id,
149+
"content": f"{result}",
150+
"source": self._agent_name,
151+
"step_id": message.step_id,
152+
},
153+
)
154+
106155
action_response = ActionResponse(
107156
step_id=step.id,
108157
plan_id=step.plan_id,

src/backend/agents/generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from agents.base_agent import BaseAgent
99
from context.cosmos_memory import CosmosBufferedChatCompletionContext
1010

11+
1112
async def dummy_function() -> str:
1213
# This is a placeholder function, for a proper Azure AI Search RAG process.
1314

0 commit comments

Comments
 (0)