Skip to content

Commit fe37ea7

Browse files
yugesh-ganipudiswaroopvarma1
authored andcommitted
- Made text color for announcement banner configurable
1 parent d1bfdd7 commit fe37ea7

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,6 @@ MEM0_ENABLED=false
174174

175175
AWS_BREEZE_PORTAL_URL="http://localhost:5173"
176176
GCP_BREEZE_PORTAL_URL="http://localhost:5174"
177+
178+
DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR=#714acd
179+
DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR=#714acd

app/agents/voice/automatic/tools/breeze/configuration.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pipecat.adapters.schemas.tools_schema import ToolsSchema
88
from pipecat.services.llm_service import FunctionCallParams
99

10-
from app.core.config import AWS_VAYU_READ_API_KEY, AWS_VAYU_URL, AWS_VAYU_WRITE_API_KEY
10+
from app.core.config import AWS_VAYU_READ_API_KEY, AWS_VAYU_URL, AWS_VAYU_WRITE_API_KEY, DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR, DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR
1111
from app.core.logger import logger
1212
from app.core.transport.http_client import create_http_client
1313

@@ -521,6 +521,7 @@ async def manage_announcement_banner(params: FunctionCallParams):
521521
action = params.arguments.get("action")
522522
description = params.arguments.get("description")
523523
background_color = params.arguments.get("background_color", None)
524+
text_color = params.arguments.get("text_color", None)
524525

525526
# Validate action
526527
if not action:
@@ -561,7 +562,20 @@ async def manage_announcement_banner(params: FunctionCallParams):
561562
if match:
562563
background_color = match.group(1)
563564
if background_color is None:
564-
background_color = "#714acd"
565+
background_color = DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR
566+
567+
if text_color is None:
568+
banner = ""
569+
if isinstance(config, dict):
570+
banner = config.get("announcementBannerText") or config.get(
571+
"loginPageAnnouncementText", ""
572+
)
573+
if isinstance(banner, str) and banner:
574+
match = re.search(r"color:\s*([^;]+);?", banner)
575+
if match:
576+
text_color = match.group(1)
577+
if text_color is None:
578+
text_color = DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR
565579

566580
except ValueError as e:
567581
logger.error(
@@ -644,7 +658,7 @@ async def manage_announcement_banner(params: FunctionCallParams):
644658
if action == BannerAction.ADD or action == BannerAction.UPDATE:
645659
# Format the description with HTML styling
646660
formatted_description = format_announcement_html(
647-
description, background_color
661+
description, background_color, text_color
648662
)
649663

650664
# Update both announcement types with the same formatted content
@@ -740,6 +754,11 @@ async def manage_announcement_banner(params: FunctionCallParams):
740754
"description": "The background color of the announcement banner. Default is #714acd (Light Purple).",
741755
"default": "#714acd",
742756
},
757+
"text_color": {
758+
"type": "string",
759+
"description": "The text color or font color of the announcement banner. Default is white.",
760+
"default": "white",
761+
},
743762
},
744763
required=["action"],
745764
)

app/agents/voice/automatic/tools/breeze/utils.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import httpx
1313

14-
from app.core.config import LIGHTHOUSE_APP_URL
14+
from app.core.config import LIGHTHOUSE_APP_URL, DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR, DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR
1515
from app.core.logger import logger
1616
from app.core.transport.http_client import create_http_client
1717

@@ -193,19 +193,28 @@ async def patch_shop_config(
193193

194194

195195
def format_announcement_html(
196-
description: str, background_color: str = "#714acd"
196+
description: str,
197+
background_color: Optional[str] = None,
198+
text_color: Optional[str] = None
197199
) -> str:
198200
"""
199201
Formats the announcement text with HTML styling.
200202
201203
Args:
202204
description: The announcement text to format
203-
background_color: The background color of the announcement banner
205+
background_color: The background color of the announcement banner (defaults to config value)
206+
text_color: The text color of the announcement banner (defaults to config value)
204207
205208
Returns:
206209
HTML formatted announcement text
207210
"""
208-
return f"<div style='text-align: center; width: 100vw;background: {background_color};color: white;padding:8px 0px;font-size:13px;'>{description}</div>"
211+
# Use config defaults if not provided
212+
if background_color is None:
213+
background_color = DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR
214+
if text_color is None:
215+
text_color = DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR
216+
217+
return f"<div style='text-align: center; width: 100vw;background: {background_color};color: {text_color};padding:8px 0px;font-size:13px;'>{description}</div>"
209218

210219

211220
def remove_html_tags(html_text: str) -> str:

app/core/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ def get_required_env(var_name: str) -> str:
379379
)
380380
AUTOMATIC_OPENAI_STT_PROMPT = os.environ.get("AUTOMATIC_OPENAI_STT_PROMPT", "")
381381

382+
# Announcement Banner Configuration
383+
DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR = os.environ.get("DEFAULT_ANNOUNCEMENT_BANNER_TEXT_COLOR", "white")
384+
DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR = os.environ.get("DEFAULT_ANNOUNCEMENT_BANNER_BACKGROUND_COLOR", "#714acd")
385+
382386
EXOTEL_ACCOUNT_SID = os.getenv("EXOTEL_ACCOUNT_SID", "")
383387
EXOTEL_API_KEY = os.getenv("EXOTEL_API_KEY", "")
384388
EXOTEL_API_TOKEN = os.getenv("EXOTEL_API_TOKEN", "")

0 commit comments

Comments
 (0)