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
5 changes: 4 additions & 1 deletion src/backend/kernel_agents/group_chat_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from context.cosmos_memory_kernel import CosmosMemoryContext
from event_utils import track_event_if_configured
from kernel_agents.agent_base import BaseAgent
from utils_date import format_date_for_user
from models.messages_kernel import (ActionRequest, AgentMessage, AgentType,
HumanFeedback, HumanFeedbackStatus, InputTask,
Plan, Step, StepStatus)
Expand Down Expand Up @@ -222,7 +223,9 @@ class Step(BaseDataModel):
received_human_feedback_on_step = ""

# Provide generic context to the model
general_information = f"Today's date is {datetime.now().date()}."
current_date = datetime.now().strftime("%Y-%m-%d")
formatted_date = format_date_for_user(current_date)
general_information = f"Today's date is {formatted_date}."

# Get the general background information provided by the user in regards to the overall plan (not the steps) to add as context.
plan = await self._memory_store.get_plan_by_session(
Expand Down
6 changes: 5 additions & 1 deletion src/backend/kernel_tools/hr_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from models.messages_kernel import AgentType
import json
from typing import get_type_hints
from utils_date import format_date_for_user


class HrTools:
Expand All @@ -15,12 +16,15 @@ class HrTools:
@staticmethod
@kernel_function(description="Schedule an orientation session for a new employee.")
async def schedule_orientation_session(employee_name: str, date: str) -> str:
formatted_date = format_date_for_user(date)

return (
f"##### Orientation Session Scheduled\n"
f"**Employee Name:** {employee_name}\n"
f"**Date:** {date}\n\n"
f"**Date:** {formatted_date}\n\n"
f"Your orientation session has been successfully scheduled. "
f"Please mark your calendar and be prepared for an informative session.\n"
f"AGENT SUMMARY: I scheduled the orientation session for {employee_name} on {formatted_date}, as part of her onboarding process.\n"
f"{HrTools.formatting_instructions}"
)

Expand Down
10 changes: 7 additions & 3 deletions src/backend/kernel_tools/product_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from models.messages_kernel import AgentType
import json
from typing import get_type_hints
from utils_date import format_date_for_user


class ProductTools:
Expand All @@ -23,10 +24,11 @@ class ProductTools:
async def add_mobile_extras_pack(new_extras_pack_name: str, start_date: str) -> str:
"""Add an extras pack/new product to the mobile plan for the customer. For example, adding a roaming plan to their service. The arguments should include the new_extras_pack_name and the start_date as strings. You must provide the exact plan name, as found using the get_product_info() function."""
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."
formatted_date = format_date_for_user(start_date)
analysis = (
f"# Request to Add Extras Pack to Mobile Plan\n"
f"## New Plan:\n{new_extras_pack_name}\n"
f"## Start Date:\n{start_date}\n\n"
f"## Start Date:\n{formatted_date}\n\n"
f"These changes have been completed and should be reflected in your app in 5-10 minutes."
f"\n\n{formatting_instructions}"
)
Expand Down Expand Up @@ -81,7 +83,8 @@ async def get_billing_date() -> str:
now = datetime.now()
start_of_month = datetime(now.year, now.month, 1)
start_of_month_string = start_of_month.strftime("%Y-%m-%d")
return f"## Billing Date\nYour most recent billing date was **{start_of_month_string}**."
formatted_date = format_date_for_user(start_of_month_string)
return f"## Billing Date\nYour most recent billing date was **{formatted_date}**."

@staticmethod
@kernel_function(
Expand Down Expand Up @@ -130,7 +133,8 @@ async def update_product_price(product_name: str, price: float) -> str:
@kernel_function(description="Schedule a product launch event on a specific date.")
async def schedule_product_launch(product_name: str, launch_date: str) -> str:
"""Schedule a product launch on a specific date."""
message = f"## Product Launch Scheduled\nProduct **'{product_name}'** launch scheduled on **{launch_date}**."
formatted_date = format_date_for_user(launch_date)
message = f"## Product Launch Scheduled\nProduct **'{product_name}'** launch scheduled on **{formatted_date}**."

return message

Expand Down
24 changes: 24 additions & 0 deletions src/backend/utils_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import locale
from datetime import datetime
import logging
from typing import Optional


def format_date_for_user(date_str: str, user_locale: Optional[str] = None) -> str:
"""
Format date based on user's desktop locale preference.

Args:
date_str (str): Date in ISO format (YYYY-MM-DD).
user_locale (str, optional): User's locale string, e.g., 'en_US', 'en_GB'.

Returns:
str: Formatted date respecting locale or raw date if formatting fails.
"""
try:
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
locale.setlocale(locale.LC_TIME, user_locale or '')
return date_obj.strftime("%B %d, %Y")
except Exception as e:
logging.warning(f"Date formatting failed for '{date_str}': {e}")
return date_str
Loading