Skip to content

Commit 36527a5

Browse files
injecting current timestamp into prompt (#214)
* injecting current timestamp into prompt * removed end conversation tool (#215)
1 parent 58d5032 commit 36527a5

2 files changed

Lines changed: 49 additions & 30 deletions

File tree

wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from copy import deepcopy
99
from call_processing.log.logger import logger
1010
from call_processing.services.tool_wrapper_service import ToolWrapperFactory
11+
from call_processing.utils import get_current_ist_time_str
1112

1213
# Pipecat core imports
1314
from pipecat.adapters.schemas.tools_schema import ToolsSchema
@@ -49,9 +50,10 @@
4950
from call_processing.services.stt_service import STTServiceFactory
5051
from call_processing.services.tts_service import TTSServiceFactory
5152
from call_processing.services.llm_service import LLMServiceFactory
52-
from call_processing.services.conversation_completion_tool import (
53-
ConversationCompletionToolFactory,
54-
)
53+
54+
# from call_processing.services.conversation_completion_tool import (
55+
# ConversationCompletionToolFactory,
56+
# )
5557
from call_processing.constants.language_config import (
5658
LANGUAGE_INSTRUCTIONS,
5759
)
@@ -300,7 +302,7 @@ async def run_conversation(
300302
# Create initial messages with system prompt
301303
base_system_prompt = (
302304
f'Customer phone number: {customer_number}\n'
303-
+ agent_config['system_prompt']
305+
f'{get_current_ist_time_str()}\n' + agent_config['system_prompt']
304306
)
305307

306308
# Add language instruction for default language if multi-language
@@ -375,34 +377,34 @@ async def run_conversation(
375377
logger.info('Registered language detection tool with LLM')
376378

377379
# Register conversation completion tool
378-
conversation_completion_func = (
379-
ConversationCompletionToolFactory.create_conversation_completion_tool(
380-
task_container=task_container
381-
)
382-
)
383-
llm.register_function('end_conversation', conversation_completion_func)
380+
# conversation_completion_func = (
381+
# ConversationCompletionToolFactory.create_conversation_completion_tool(
382+
# task_container=task_container
383+
# )
384+
# )
385+
# llm.register_function('end_conversation', conversation_completion_func)
384386
logger.info('Registered conversation completion tool with LLM')
385387

386388
# Create FunctionSchema for conversation completion
387-
end_conversation_schema = FunctionSchema(
388-
name='end_conversation',
389-
description=(
390-
'Call this function when the user indicates they want to end the conversation. '
391-
'This includes goodbye phrases, expressions of completion, or any indication '
392-
'that the user wants to hang up or finish the call. Examples: "goodbye", "bye", '
393-
'"thank you", "that\'s all", "I\'m done", etc.'
394-
),
395-
properties={
396-
'farewell_message': {
397-
'type': 'string',
398-
'description': (
399-
'Optional custom farewell message to say to the user before ending. '
400-
'If not provided, uses default: "Thank you for using our service! Goodbye!"'
401-
),
402-
}
403-
},
404-
required=[],
405-
)
389+
# end_conversation_schema = FunctionSchema(
390+
# name='end_conversation',
391+
# description=(
392+
# 'Call this function when the user indicates they want to end the conversation. '
393+
# 'This includes goodbye phrases, expressions of completion, or any indication '
394+
# 'that the user wants to hang up or finish the call. Examples: "goodbye", "bye", '
395+
# '"thank you", "that\'s all", "I\'m done", etc.'
396+
# ),
397+
# properties={
398+
# 'farewell_message': {
399+
# 'type': 'string',
400+
# 'description': (
401+
# 'Optional custom farewell message to say to the user before ending. '
402+
# 'If not provided, uses default: "Thank you for using our service! Goodbye!"'
403+
# ),
404+
# }
405+
# },
406+
# required=[],
407+
# )
406408

407409
# Create FunctionSchema for language detection (if multi-language)
408410
language_detection_schemas = []
@@ -435,7 +437,8 @@ async def run_conversation(
435437

436438
# Combine all FunctionSchema objects for ToolsSchema
437439
all_function_schemas = (
438-
[end_conversation_schema] + language_detection_schemas + function_schemas
440+
# [end_conversation_schema] +
441+
language_detection_schemas + function_schemas
439442
)
440443
tools_schema = ToolsSchema(standard_tools=all_function_schemas)
441444

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from datetime import datetime, timedelta, timezone
2+
3+
4+
def get_current_ist_time_str() -> str:
5+
"""Return current date, time, and day in IST as a formatted string."""
6+
ist_offset = timedelta(hours=5, minutes=30)
7+
ist_time = datetime.now(timezone.utc) + ist_offset
8+
current_time = ist_time.strftime('%Y-%m-%d %H:%M:%S')
9+
current_day = ist_time.strftime('%A')
10+
return (
11+
f'Current Date and Time (IST): {current_time}, {current_day}\n'
12+
'- The user always speaks time in IST.\n'
13+
"- If the user says 'tomorrow', calculate the date based on today's date.\n"
14+
"- If the user says 'Monday', 'next Friday', etc., calculate the correct date relative to today.\n"
15+
"- Always convert relative dates (like 'tomorrow', 'next week') to specific dates (YYYY-MM-DD) when calling tools."
16+
)

0 commit comments

Comments
 (0)