Skip to content

Commit 0970f67

Browse files
Testcases
2 parents 7966c45 + 3415894 commit 0970f67

32 files changed

+734
-390
lines changed

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

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

3434
- name: Log in to Azure Container Registry
35-
35+
if: ${{ inputs.push == true && (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 }}
@@ -50,17 +50,27 @@ jobs:
5050
echo "TAG=demo" >> $GITHUB_ENV
5151
elif [[ "${{ github.head.ref }}" == "hotfix" ]]; then
5252
echo "TAG=hotfix" >> $GITHUB_ENV
53+
else
54+
echo "TAG=pullrequest-ignore" >> $GITHUB_ENV
5355
fi
54-
- name: Build and push Docker images
55-
56+
57+
- name: Build and push Docker images optionally
5658
run: |
5759
cd src/backend
5860
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} -f Dockerfile . && \
59-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
60-
echo "Backend image built and pushed successfully."
61+
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
62+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
63+
echo "Backend image built and pushed successfully."
64+
else
65+
echo "Skipping Docker push for backend with tag: ${{ env.TAG }}"
66+
fi
6167
cd ../frontend
6268
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} -f Dockerfile . && \
63-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
64-
echo "Frontend image built and pushed successfully."
69+
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" || "${{ env.TAG }}" == "hotfix" ]]; then
70+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
71+
echo "Frontend image built and pushed successfully."
72+
else
73+
echo "Skipping Docker push for frontend with tag: ${{ env.TAG }}"
74+
fi
6575
6676

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 src.backend.context.cosmos_memory import CosmosBufferedChatCompletionContext
8-
from src.backend.models.messages import InputTask, PlanStatus, Step, StepStatus
10+
from src.backend.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: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@
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 src.backend.context.cosmos_memory import CosmosBufferedChatCompletionContext
14-
from src.backend.models.messages import (ActionRequest, ActionResponse,
15-
AgentMessage, Step, StepStatus)
17+
from src.backend.models.messages import (
18+
ActionRequest,
19+
ActionResponse,
20+
AgentMessage,
21+
Step,
22+
StepStatus,
23+
)
1624
from azure.monitor.events.extension import track_event
1725

26+
1827
class BaseAgent(RoutedAgent):
1928
def __init__(
2029
self,
@@ -95,7 +104,7 @@ async def handle_action_request(
95104
step_id=message.step_id,
96105
)
97106
)
98-
107+
99108
track_event(
100109
"Base agent - Added into the cosmos",
101110
{
@@ -107,7 +116,7 @@ async def handle_action_request(
107116
"step_id": message.step_id,
108117
},
109118
)
110-
119+
111120
except Exception as e:
112121
logging.exception(f"Error during LLM call: {e}")
113122
track_event(
@@ -121,14 +130,14 @@ async def handle_action_request(
121130
"step_id": message.step_id,
122131
},
123132
)
124-
133+
125134
return
126135
print(f"Task completed: {result}")
127136

128137
step.status = StepStatus.completed
129138
step.agent_reply = result
130139
await self._model_context.update_step(step)
131-
140+
132141
track_event(
133142
"Base agent - Updated step and updated into the cosmos",
134143
{

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 src.backend.agents.base_agent import BaseAgent
99
from src.backend.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

src/backend/agents/group_chat_manager.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@
1212
from src.backend.context.cosmos_memory import CosmosBufferedChatCompletionContext
1313
from src.backend.models.messages import (
1414
ActionRequest,
15-
ActionResponse,
1615
AgentMessage,
17-
ApprovalRequest,
1816
BAgentType,
1917
HumanFeedback,
2018
HumanFeedbackStatus,
2119
InputTask,
2220
Plan,
23-
PlanStatus,
2421
Step,
2522
StepStatus,
2623
)
2724

28-
from datetime import datetime
29-
from typing import List
3025
from azure.monitor.events.extension import track_event
3126

3227

@@ -291,12 +286,10 @@ async def _execute_step(self, session_id: str, step: Step):
291286
agent=step.agent,
292287
)
293288
logging.info(f"Sending ActionRequest to {step.agent.value}")
294-
289+
295290
if step.agent != "":
296291
agent_name = step.agent.value
297-
formatted_agent = re.sub(
298-
r"([a-z])([A-Z])", r"\1 \2", agent_name
299-
)
292+
formatted_agent = re.sub(r"([a-z])([A-Z])", r"\1 \2", agent_name)
300293
else:
301294
raise ValueError(f"Check {step.agent} is missing")
302295

src/backend/agents/human.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
import logging
33

44
from autogen_core.base import AgentId, MessageContext
5-
from autogen_core.components import (RoutedAgent, default_subscription,
6-
message_handler)
5+
from autogen_core.components import RoutedAgent, default_subscription, message_handler
76

87
from src.backend.context.cosmos_memory import CosmosBufferedChatCompletionContext
98
from src.backend.models.messages import (
109
ApprovalRequest,
1110
HumanFeedback,
12-
HumanClarification,
13-
HumanFeedbackStatus,
1411
StepStatus,
1512
AgentMessage,
1613
Step,
@@ -23,7 +20,7 @@ class HumanAgent(RoutedAgent):
2320
def __init__(
2421
self,
2522
memory: CosmosBufferedChatCompletionContext,
26-
user_id:str,
23+
user_id: str,
2724
group_chat_manager_id: AgentId,
2825
) -> None:
2926
super().__init__("HumanAgent")
@@ -83,7 +80,7 @@ async def handle_step_feedback(
8380
)
8481
)
8582
logging.info(f"HumanAgent sent approval request for step: {step}")
86-
83+
8784
track_event(
8885
f"Human Agent - Approval request sent for step {step} and added into the cosmos",
8986
{

0 commit comments

Comments
 (0)