Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
53 changes: 53 additions & 0 deletions src/backend/agents/baker_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from autogen_core.base import AgentId
from autogen_core.components.models import AzureOpenAIChatCompletionClient
from autogen_core.components.tools import Tool
from autogen_core.components.tool_agent import ToolAgent
from agents.base_agent import BaseAgent
from typing import List
from context.cosmos_memory import CosmosBufferedChatCompletionContext

# Define Baker tools (functions)
async def bake_cookies(cookie_type: str, quantity: int) -> str:
return f"Baked {quantity} {cookie_type} cookies."

async def prepare_dough(dough_type: str) -> str:
return f"Prepared {dough_type} dough."

# Function to return Baker tools
def get_baker_tools() -> List[Tool]:
from autogen_core.components.tools import FunctionTool

return [
FunctionTool(
bake_cookies,
description="Bake cookies of a specific type.",
name="bake_cookies",
),
FunctionTool(
prepare_dough,
description="Prepare dough of a specific type.",
name="prepare_dough",
),
]

# Define the BakerAgent class
class BakerAgent(BaseAgent):
def __init__(
self,
model_client: AzureOpenAIChatCompletionClient,
session_id: str,
user_id: str,
memory: CosmosBufferedChatCompletionContext,
tools: List[Tool],
agent_id: AgentId,
):
super().__init__(
"BakerAgent",
model_client,
session_id,
user_id,
memory,
tools,
agent_id,
system_message="You are an AI Agent specialized in baking tasks. You can bake cookies and prepare dough based on user requests.",
)
1 change: 1 addition & 0 deletions src/backend/models/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BAgentType(str, Enum):
tech_support_agent = "TechSupportAgent"
group_chat_manager = "GroupChatManager"
planner_agent = "PlannerAgent"
baker_agent = "BakerAgent"

# Add other agents as needed

Expand Down
33 changes: 32 additions & 1 deletion src/backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from agents.product import ProductAgent, get_product_tools
from agents.generic import GenericAgent, get_generic_tools
from agents.tech_support import TechSupportAgent, get_tech_support_tools
from agents.baker_agent import BakerAgent, get_baker_tools

# from agents.misc import MiscAgent
from config import Config
Expand Down Expand Up @@ -49,7 +50,7 @@
product_tools = get_product_tools()
generic_tools = get_generic_tools()
tech_support_tools = get_tech_support_tools()

baker_tools = get_baker_tools()

# Initialize the Azure OpenAI model client
aoai_model_client = Config.GetAzureOpenAIChatCompletionClient(
Expand Down Expand Up @@ -102,6 +103,8 @@ async def initialize_runtime_and_context(
generic_tool_agent_id = AgentId("generic_tool_agent", session_id)
tech_support_agent_id = AgentId("tech_support_agent", session_id)
tech_support_tool_agent_id = AgentId("tech_support_tool_agent", session_id)
baker_agent_id = AgentId("baker_agent", session_id)
baker_tool_agent_id = AgentId("baker_tool_agent", session_id)
group_chat_manager_id = AgentId("group_chat_manager", session_id)

# Initialize the context for the session
Expand Down Expand Up @@ -139,6 +142,11 @@ async def initialize_runtime_and_context(
"tech_support_tool_agent",
lambda: ToolAgent("Tech support tool execution agent", tech_support_tools),
)
await ToolAgent.register(
runtime,
"baker_tool_agent",
lambda: ToolAgent("Baker tool execution agent", baker_tools),
)
await ToolAgent.register(
runtime,
"misc_tool_agent",
Expand Down Expand Up @@ -241,6 +249,18 @@ async def initialize_runtime_and_context(
tech_support_tool_agent_id,
),
)
await BakerAgent.register(
runtime,
baker_agent_id.type,
lambda: BakerAgent(
aoai_model_client,
session_id,
user_id,
cosmos_memory,
baker_tools,
baker_tool_agent_id,
),
)
await HumanAgent.register(
runtime,
human_agent_id.type,
Expand All @@ -256,6 +276,7 @@ async def initialize_runtime_and_context(
BAgentType.product_agent: product_agent_id,
BAgentType.generic_agent: generic_agent_id,
BAgentType.tech_support_agent: tech_support_agent_id,
BAgentType.baker_agent: baker_agent_id,
}
await GroupChatManager.register(
runtime,
Expand All @@ -280,6 +301,7 @@ def retrieve_all_agent_tools() -> List[Dict[str, Any]]:
procurement_tools: List[Tool] = get_procurement_tools()
product_tools: List[Tool] = get_product_tools()
tech_support_tools: List[Tool] = get_tech_support_tools()
baker_tools: List[Tool] = get_baker_tools()

functions = []

Expand Down Expand Up @@ -326,6 +348,15 @@ def retrieve_all_agent_tools() -> List[Dict[str, Any]]:
"arguments": str(tool.schema["parameters"]["properties"]),
}
)
for tool in baker_tools:
functions.append(
{
"agent": "BakerAgent",
"function": tool.name,
"description": tool.description,
"arguments": str(tool.schema["parameters"]["properties"]),
}
)

# Add ProductAgent functions
for tool in product_tools:
Expand Down
10 changes: 10 additions & 0 deletions src/frontend/wwwroot/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ <h2 class="title has-text-centered">Quick tasks</h2>
</div>
</div>
</div>
<div class="column">
<div class="card is-hoverable quick-task">
<div class="card-content">
<i class="fa-solid fa-list-check has-text-info mb-3"></i><br />
<strong>Bake Cookies</strong>
<p class="quick-task-prompt">Please bake 12 chocolate chip cookies for tomorrow's event.</p>
</div>
</div>
</div>

</section>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/wwwroot/task/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
case "GenericAgent":
agentIcon = "manager";
break;
case "BakerAgent":
agentIcon = "manager";
Copy link

Copilot AI Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agentIcon for BakerAgent is incorrectly set to 'manager'. It should be set to an icon related to baking.

Suggested change
agentIcon = "manager";
agentIcon = 'baker';

Copilot uses AI. Check for mistakes.
break;
case "HumanAgent":
let userNumber = sessionStorage.getItem("userNumber");
if (userNumber == null) {
Expand Down
Loading