Skip to content

Commit

Permalink
fix: UI Enhancements, Error handling, Docker integration and other bu…
Browse files Browse the repository at this point in the history
…g fixes (#52)

* fix: ui changes (#1)

* fix: in progress status color after fetch task details (#5)

* cancel notification message updated (#7)

* Update task.js (#9)

* Stages overflow issue fix (#10)

* fix: added space to the agent (#13)

* Approve reject buttons titles disabling buttons and (#15)

* Fix: UX becomes damaged when chat outputs sample code for a task (#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 (#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 (#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 (#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 (#43)

* Disabling Text Area functionality (#47)

* fix: Usability and Alignments changes (#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 (#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]>
  • Loading branch information
5 people authored Jan 27, 2025
1 parent fcf538e commit 3bf5016
Show file tree
Hide file tree
Showing 28 changed files with 578 additions and 210 deletions.
48 changes: 20 additions & 28 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,13 @@ jobs:
uses: docker/setup-buildx-action@v1

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

- name: Log in to Azure Container Registry (Dev/Demo)
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
username: ${{ secrets.ACR_DEV_USERNAME }}
password: ${{ secrets.ACR_DEV_PASSWORD }}

- name: Set Docker image tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
Expand All @@ -57,27 +49,27 @@ jobs:
echo "TAG=demo" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then
echo "TAG=hotfix" >> $GITHUB_ENV
else
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
fi
- name: Build and push Docker images
if: ${{ github.ref_name == 'main' }}
run: |
cd src/backend
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \
echo "Backend image built and pushed successfully."
cd ../frontend
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \
docker push ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \
echo "Frontend image built and pushed successfully."
- name: Build and push Docker images (Dev/Demo/hotfix)
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }}
- name: Build and push Docker images optionally
run: |
cd src/backend
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \
echo "Dev/Demo/Hotfix Backend image built and pushed successfully."
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} -f Dockerfile . && \
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
echo "Backend image built and pushed successfully."
else
echo "Skipping Docker push for backend with tag: ${{ env.TAG }}"
fi
cd ../frontend
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \
echo "Dev/Demo/Hotfix Frontend image built and pushed successfully."
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} -f Dockerfile . && \
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
echo "Frontend image built and pushed successfully."
else
echo "Skipping Docker push for frontend with tag: ${{ env.TAG }}"
fi
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r src/backend/requirements.txt
pip install pytest-cov
pip install pytest-asyncio
- name: Check if test files exist
id: check_tests
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ To add your newly created backend image:
name: 'FRONTEND_SITE_NAME'
value: 'https://<website Name>.azurewebsites.net'

name: 'APPLICATIONINSIGHTS_INSTRUMENTATION_KEY'
value: <Application Insights Instrumentation Key>

- Click 'Save' and deploy your new revision

To add the new container to your website run the following:
Expand Down
7 changes: 6 additions & 1 deletion deploy/macae-continer-oc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "17567587246932458853"
"templateHash": "13282901028774763433"
}
},
"parameters": {
Expand Down Expand Up @@ -366,13 +366,18 @@
{
"name": "FRONTEND_SITE_NAME",
"value": "[format('https://{0}.azurewebsites.net', format(variables('uniqueNameFormat'), 'frontend'))]"
},
{
"name": "APPLICATIONINSIGHTS_INSTRUMENTATION_KEY",
"value": "[reference('appInsights').ConnectionString]"
}
]
}
]
}
},
"dependsOn": [
"appInsights",
"cosmos::autogenDb",
"containerAppEnv",
"cosmos",
Expand Down
4 changes: 4 additions & 0 deletions deploy/macae-continer.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
name: 'FRONTEND_SITE_NAME'
value: 'https://${format(uniqueNameFormat, 'frontend')}.azurewebsites.net'
}
{
name: 'APPLICATIONINSIGHTS_INSTRUMENTATION_KEY'
value: appInsights.properties.ConnectionString
}
]
}
]
Expand Down
1 change: 1 addition & 0 deletions src/backend/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COSMOSDB_CONTAINER=memory
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o
AZURE_OPENAI_API_VERSION=2024-08-01-preview
APPLICATIONINSIGHTS_INSTRUMENTATION_KEY=

BACKEND_API_URL='http://localhost:8000'
FRONTEND_SITE_NAME='http://127.0.0.1:3000'
10 changes: 6 additions & 4 deletions src/backend/agents/agentutils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import json

from autogen_core.components.models import (AssistantMessage,
AzureOpenAIChatCompletionClient)
from autogen_core.components.models import (
AssistantMessage,
AzureOpenAIChatCompletionClient,
)
from pydantic import BaseModel

from context.cosmos_memory import CosmosBufferedChatCompletionContext
from models.messages import InputTask, PlanStatus, Step, StepStatus
from models.messages import Step

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?"

Expand All @@ -27,7 +29,7 @@ class FSMStateAndTransition(BaseModel):
identifiedTargetState: str
identifiedTargetTransition: str

cosmos = CosmosBufferedChatCompletionContext(session_id or "",user_id)
cosmos = CosmosBufferedChatCompletionContext(session_id or "", user_id)
combined_LLM_messages = [
AssistantMessage(content=step.action, source="GroupChatManager")
]
Expand Down
63 changes: 56 additions & 7 deletions src/backend/agents/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@

from autogen_core.base import AgentId, MessageContext
from autogen_core.components import RoutedAgent, message_handler
from autogen_core.components.models import (AssistantMessage,
AzureOpenAIChatCompletionClient,
LLMMessage, SystemMessage,
UserMessage)
from autogen_core.components.models import (
AssistantMessage,
AzureOpenAIChatCompletionClient,
LLMMessage,
SystemMessage,
UserMessage,
)
from autogen_core.components.tool_agent import tool_agent_caller_loop
from autogen_core.components.tools import Tool

from context.cosmos_memory import CosmosBufferedChatCompletionContext
from models.messages import (ActionRequest, ActionResponse,
AgentMessage, Step, StepStatus)
from models.messages import (
ActionRequest,
ActionResponse,
AgentMessage,
Step,
StepStatus,
)
from azure.monitor.events.extension import track_event


class BaseAgent(RoutedAgent):
def __init__(
Expand Down Expand Up @@ -94,15 +104,54 @@ async def handle_action_request(
step_id=message.step_id,
)
)

track_event(
"Base agent - Added into the cosmos",
{
"session_id": message.session_id,
"user_id": self._user_id,
"plan_id": message.plan_id,
"content": f"{result}",
"source": self._agent_name,
"step_id": message.step_id,
},
)

except Exception as e:
print(f"Error during LLM call: {e}")
logging.exception(f"Error during LLM call: {e}")
track_event(
"Base agent - Error during llm call, captured into the cosmos",
{
"session_id": message.session_id,
"user_id": self._user_id,
"plan_id": message.plan_id,
"content": f"{e}",
"source": self._agent_name,
"step_id": message.step_id,
},
)

return
print(f"Task completed: {result}")

step.status = StepStatus.completed
step.agent_reply = result
await self._model_context.update_step(step)

track_event(
"Base agent - Updated step and updated into the cosmos",
{
"status": StepStatus.completed,
"session_id": message.session_id,
"agent_reply": f"{result}",
"user_id": self._user_id,
"plan_id": message.plan_id,
"content": f"{result}",
"source": self._agent_name,
"step_id": message.step_id,
},
)

action_response = ActionResponse(
step_id=step.id,
plan_id=step.plan_id,
Expand Down
1 change: 1 addition & 0 deletions src/backend/agents/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from agents.base_agent import BaseAgent
from context.cosmos_memory import CosmosBufferedChatCompletionContext


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

Expand Down
Loading

0 comments on commit 3bf5016

Please sign in to comment.