Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
uses: docker/setup-buildx-action@v1

- name: Log in to Azure Container Registry
if: ${{ inputs.push == true && (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 }}
Expand All @@ -48,15 +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

- name: Build and push Docker images optionally
run: |
cd src/backend
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} -f Dockerfile . && \
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaebackend:${{ env.TAG }} && \
echo "Backend image built and pushed successfully."
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_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} -f Dockerfile . && \
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macaefrontend:${{ env.TAG }} && \
echo "Frontend image built and pushed successfully."
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


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
29 changes: 19 additions & 10 deletions src/backend/agents/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@

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__(
self,
Expand Down Expand Up @@ -95,7 +104,7 @@ async def handle_action_request(
step_id=message.step_id,
)
)

track_event(
"Base agent - Added into the cosmos",
{
Expand All @@ -107,7 +116,7 @@ async def handle_action_request(
"step_id": message.step_id,
},
)

except Exception as e:
logging.exception(f"Error during LLM call: {e}")
track_event(
Expand All @@ -121,14 +130,14 @@ async def handle_action_request(
"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",
{
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
11 changes: 2 additions & 9 deletions src/backend/agents/group_chat_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@
from context.cosmos_memory import CosmosBufferedChatCompletionContext
from models.messages import (
ActionRequest,
ActionResponse,
AgentMessage,
ApprovalRequest,
BAgentType,
HumanFeedback,
HumanFeedbackStatus,
InputTask,
Plan,
PlanStatus,
Step,
StepStatus,
)

from datetime import datetime
from typing import List
from azure.monitor.events.extension import track_event


Expand Down Expand Up @@ -291,12 +286,10 @@ async def _execute_step(self, session_id: str, step: Step):
agent=step.agent,
)
logging.info(f"Sending ActionRequest to {step.agent.value}")

if step.agent != "":
agent_name = step.agent.value
formatted_agent = re.sub(
r"([a-z])([A-Z])", r"\1 \2", agent_name
)
formatted_agent = re.sub(r"([a-z])([A-Z])", r"\1 \2", agent_name)
else:
raise ValueError(f"Check {step.agent} is missing")

Expand Down
9 changes: 3 additions & 6 deletions src/backend/agents/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
import logging

from autogen_core.base import AgentId, MessageContext
from autogen_core.components import (RoutedAgent, default_subscription,
message_handler)
from autogen_core.components import RoutedAgent, default_subscription, message_handler

from context.cosmos_memory import CosmosBufferedChatCompletionContext
from models.messages import (
ApprovalRequest,
HumanFeedback,
HumanClarification,
HumanFeedbackStatus,
StepStatus,
AgentMessage,
Step,
Expand All @@ -23,7 +20,7 @@ class HumanAgent(RoutedAgent):
def __init__(
self,
memory: CosmosBufferedChatCompletionContext,
user_id:str,
user_id: str,
group_chat_manager_id: AgentId,
) -> None:
super().__init__("HumanAgent")
Expand Down Expand Up @@ -83,7 +80,7 @@ async def handle_step_feedback(
)
)
logging.info(f"HumanAgent sent approval request for step: {step}")

track_event(
f"Human Agent - Approval request sent for step {step} and added into the cosmos",
{
Expand Down
Loading
Loading