Skip to content

Commit 31ee6b2

Browse files
authored
Merge pull request #146 from microsoft/psl-tools-fixed
fix: initialization logic across multiple agent classes and renames various kernel tool methods
2 parents 5396e45 + 773d597 commit 31ee6b2

File tree

12 files changed

+21
-27
lines changed

12 files changed

+21
-27
lines changed

src/backend/kernel_agents/generic_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(
4141
definition: Optional definition instance
4242
"""
4343
# Load configuration if tools not provided
44-
if tools is None:
44+
if not tools:
4545
# Get tools directly from GenericTools class
4646
tools_dict = GenericTools.get_all_kernel_functions()
4747
logging.info(

src/backend/kernel_agents/hr_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
definition: Optional definition instance
4545
"""
4646
# Load configuration if tools not provided
47-
if tools is None:
47+
if not tools:
4848
# Get tools directly from HrTools class
4949
tools_dict = HrTools.get_all_kernel_functions()
5050
tools = [KernelFunction.from_method(func) for func in tools_dict.values()]

src/backend/kernel_agents/human_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(
5555
definition: Optional definition instance
5656
"""
5757
# Load configuration if tools not provided
58-
if tools is None:
58+
if not tools:
5959
# Get tools directly from HumanTools class
6060
tools_dict = HumanTools.get_all_kernel_functions()
6161
tools = [KernelFunction.from_method(func) for func in tools_dict.values()]

src/backend/kernel_agents/marketing_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
definition: Optional definition instance
4444
"""
4545
# Load configuration if tools not provided
46-
if tools is None:
46+
if not tools:
4747
# Get tools directly from MarketingTools class
4848
tools_dict = MarketingTools.get_all_kernel_functions()
4949
tools = [KernelFunction.from_method(func) for func in tools_dict.values()]

src/backend/kernel_agents/procurement_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
definition: Optional definition instance
4444
"""
4545
# Load configuration if tools not provided
46-
if tools is None:
46+
if not tools:
4747
# Get tools directly from ProcurementTools class
4848
tools_dict = ProcurementTools.get_all_kernel_functions()
4949
tools = [KernelFunction.from_method(func) for func in tools_dict.values()]

src/backend/kernel_agents/product_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(
4646
definition: Optional definition instance
4747
"""
4848
# Load configuration if tools not provided
49-
if tools is None:
49+
if not tools:
5050
# Get tools directly from ProductTools class
5151
tools_dict = ProductTools.get_all_kernel_functions()
5252
tools = [KernelFunction.from_method(func) for func in tools_dict.values()]

src/backend/kernel_agents/tech_support_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
definition: Optional definition instance
4444
"""
4545
# Load configuration if tools not provided
46-
if tools is None:
46+
if not tools:
4747
# Get tools directly from TechSupportTools class
4848
tools_dict = TechSupportTools.get_all_kernel_functions()
4949
tools = [KernelFunction.from_method(func) for func in tools_dict.values()]

src/backend/kernel_tools/hr_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ async def track_employee_attendance(employee_name: str) -> str:
271271

272272
@staticmethod
273273
@kernel_function(description="Organize a health and wellness program.")
274-
async def organize_health_and_wellness_program(program_name: str, date: str) -> str:
274+
async def organize_wellness_program(program_name: str, date: str) -> str:
275275
return (
276276
f"##### Health and Wellness Program Organized\n"
277277
f"**Program Name:** {program_name}\n"

src/backend/kernel_tools/marketing_tools.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def analyze_market_trends(industry: str) -> str:
2323

2424
@staticmethod
2525
@kernel_function(description="Generate social media posts for a campaign.")
26-
async def generate_social_media_posts(campaign_name: str, platforms: list) -> str:
26+
async def generate_social_posts(campaign_name: str, platforms: list) -> str:
2727
platforms_str = ", ".join(platforms)
2828
return f"Social media posts for campaign '{campaign_name}' generated for platforms: {platforms_str}."
2929

@@ -44,12 +44,6 @@ async def conduct_customer_survey(survey_topic: str, target_group: str) -> str:
4444
async def perform_competitor_analysis(competitor_name: str) -> str:
4545
return f"Competitor analysis performed on '{competitor_name}'."
4646

47-
@staticmethod
48-
@kernel_function(description="Optimize SEO strategy using specified keywords.")
49-
async def optimize_seo_strategy(keywords: list) -> str:
50-
keywords_str = ", ".join(keywords)
51-
return f"SEO strategy optimized with keywords: {keywords_str}."
52-
5347
@staticmethod
5448
@kernel_function(description="Schedule a marketing event.")
5549
async def schedule_marketing_event(
@@ -211,7 +205,7 @@ async def organize_trade_show(booth_number: str, event_name: str) -> str:
211205

212206
@staticmethod
213207
@kernel_function(description="Manage a customer retention program.")
214-
async def manage_customer_retention_program(program_name: str) -> str:
208+
async def manage_retention_program(program_name: str) -> str:
215209
return f"Customer retention program '{program_name}' managed."
216210

217211
@staticmethod
@@ -261,7 +255,7 @@ async def optimize_conversion_funnel(stage: str) -> str:
261255

262256
@staticmethod
263257
@kernel_function(description="Run an influencer marketing campaign.")
264-
async def run_influencer_marketing_campaign(
258+
async def run_influencer_campaign(
265259
campaign_name: str, influencers: list
266260
) -> str:
267261
influencers_str = ", ".join(influencers)
@@ -280,15 +274,15 @@ async def develop_customer_personas(segment_name: str) -> str:
280274
# This function does NOT have the kernel_function annotation
281275
# because it's meant for introspection rather than being exposed as a tool
282276
@staticmethod
283-
def get_all_kernel_functions() -> List[Callable]:
277+
def get_all_kernel_functions() -> dict[str, Callable]:
284278
"""
285279
Returns a dictionary of all methods in this class that have the @kernel_function annotation.
286280
This function itself is not annotated with @kernel_function.
287281
288282
Returns:
289283
Dict[str, Callable]: Dictionary with function names as keys and function objects as values
290284
"""
291-
kernel_functions = []
285+
kernel_functions = {}
292286

293287
# Get all class methods
294288
for name, method in inspect.getmembers(
@@ -304,6 +298,6 @@ def get_all_kernel_functions() -> List[Callable]:
304298
if hasattr(method, "__kernel_function__") or "kernel_function" in str(
305299
method_attrs
306300
):
307-
kernel_functions.append(method)
301+
kernel_functions[name] = method
308302

309303
return kernel_functions

src/backend/kernel_tools/procurement_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ async def verify_delivery(item_name: str, delivery_status: str) -> str:
466466
)
467467

468468
@staticmethod
469-
@kernel_function(description="Handle procurement risk assessment.")
470-
async def handle_procurement_risk_assessment(risk_details: str) -> str:
469+
@kernel_function(description="assess procurement risk assessment.")
470+
async def assess_procurement_risk(risk_details: str) -> str:
471471
return (
472472
f"##### Procurement Risk Assessment\n"
473473
f"**Details:** {risk_details}\n\n"

0 commit comments

Comments
 (0)