Skip to content

Commit 67cd66b

Browse files
committed
Merge branch 'feature/azd-kernel-invoke-marktayl'
2 parents 2a794da + eb6c85d commit 67cd66b

File tree

12 files changed

+2296
-27
lines changed

12 files changed

+2296
-27
lines changed

src/backend/kernel_agents/agent_base.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import logging
21
import json
2+
import logging
33
import os
4-
from typing import Any, Dict, List, Mapping, Optional, Callable, Awaitable
4+
from typing import Any, Awaitable, Callable, Dict, List, Mapping, Optional, Union
55

66
import semantic_kernel as sk
7+
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent
78
from semantic_kernel.functions import KernelFunction
8-
from semantic_kernel.functions.kernel_function_decorator import kernel_function
99
from semantic_kernel.functions.kernel_arguments import KernelArguments
10-
from semantic_kernel.agents.azure_ai.azure_ai_agent import AzureAIAgent
10+
from semantic_kernel.functions.kernel_function_decorator import kernel_function
1111

1212
# Updated imports for compatibility
1313
try:
1414
# Try importing from newer structure first
15-
from semantic_kernel.contents import ChatMessageContent, ChatHistory
15+
from semantic_kernel.contents import ChatHistory, ChatMessageContent
1616
except ImportError:
1717
# Fall back to older structure for compatibility
1818
class ChatMessageContent:
@@ -30,7 +30,10 @@ def __init__(self):
3030
self.messages = []
3131

3232

33+
# Import the new AppConfig instance
34+
from app_config import config
3335
from context.cosmos_memory_kernel import CosmosMemoryContext
36+
from event_utils import track_event_if_configured
3437
from models.messages_kernel import (
3538
ActionRequest,
3639
ActionResponse,
@@ -39,10 +42,6 @@ def __init__(self):
3942
StepStatus,
4043
)
4144

42-
# Import the new AppConfig instance
43-
from app_config import config
44-
from event_utils import track_event_if_configured
45-
4645
# Default formatting instructions used across agents
4746
DEFAULT_FORMATTING_INSTRUCTIONS = "Instructions: returning the output of this function call verbatim to the user in markdown. Then write AGENT SUMMARY: and then include a summary of what you did."
4847

@@ -77,6 +76,8 @@ def __init__(
7776
client: The client required by AzureAIAgent
7877
definition: The definition required by AzureAIAgent
7978
"""
79+
# Add plugins if not already set
80+
# if not self.plugins:
8081
# If agent_type is provided, load tools from config automatically
8182
if agent_type and not tools:
8283
tools = self.get_tools_from_config(kernel, agent_type)
@@ -94,6 +95,7 @@ def __init__(
9495
super().__init__(
9596
kernel=kernel,
9697
deployment_name=None, # Set as needed
98+
plugins=None, # Use the loaded plugins,
9799
endpoint=None, # Set as needed
98100
api_version=None, # Set as needed
99101
token=None, # Set as needed
@@ -120,6 +122,15 @@ def __init__(
120122
# Register the handler functions
121123
self._register_functions()
122124

125+
# @property
126+
# def plugins(self) -> Optional[dict[str, Callable]]:
127+
# """Get the plugins for this agent.
128+
129+
# Returns:
130+
# A list of plugins, or None if not applicable.
131+
# """
132+
# return None
133+
123134
def _default_system_message(self, agent_name=None) -> str:
124135
name = agent_name or getattr(self, "_agent_name", "Agent")
125136
return f"You are an AI assistant named {name}. Help the user by providing accurate and helpful information."
@@ -202,7 +213,9 @@ async def handle_action_request(self, action_request: ActionRequest) -> str:
202213

203214
# Call the agent to handle the action
204215
async_generator = self._agent.invoke(
205-
f"{action_request.action}\n\nPlease perform this action"
216+
# messages=f"{json.dumps(self._chat_history)}\n\n
217+
messages=f"{action_request.action}\n\nPlease perform this action"
218+
# messages=action_request.action
206219
)
207220

208221
response_content = ""
@@ -477,7 +490,7 @@ def get_tools_from_config(
477490
plugin_name = f"{agent_type}_plugin"
478491

479492
# Early return if no tools defined - prevent empty iteration
480-
if not config.get("tools"):
493+
if not config.get("tools"): # or agent_type == "Product_Agent":
481494
logging.info(
482495
f"No tools defined for agent type '{agent_type}'. Returning empty list."
483496
)

src/backend/kernel_agents/hr_tools.py

Whitespace-only changes.

src/backend/kernel_agents/marketing_agent.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from typing import List, Optional
22

33
import semantic_kernel as sk
4-
from semantic_kernel.functions import KernelFunction
5-
6-
from kernel_agents.agent_base import BaseAgent
74
from context.cosmos_memory_kernel import CosmosMemoryContext
5+
from kernel_agents.agent_base import BaseAgent
6+
from kernel_agents.marketing_tools import MarketingTools
87
from models.messages_kernel import AgentType
8+
from semantic_kernel.functions import KernelFunction
99

1010

1111
class MarketingAgent(BaseAgent):
@@ -48,7 +48,7 @@ def __init__(
4848
if tools is None:
4949
# Load the marketing tools configuration
5050
config = self.load_tools_config("marketing", config_path)
51-
tools = self.get_tools_from_config(kernel, "marketing", config_path)
51+
tools = self.get_tools(kernel, "marketing", config_path)
5252

5353
# Use system message from config if not explicitly provided
5454
if not system_message:
@@ -71,3 +71,8 @@ def __init__(
7171
client=client,
7272
definition=definition,
7373
)
74+
75+
# @property
76+
# def plugins(self):
77+
# """Get the plugins for the syntax checker agent."""
78+
# return ["marketing_functions", MarketingTools()]

0 commit comments

Comments
 (0)