|
7 | 7 | from pipecat.adapters.schemas.tools_schema import ToolsSchema |
8 | 8 | from pipecat.services.llm_service import FunctionCallParams |
9 | 9 |
|
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 |
11 | 11 | from app.core.logger import logger |
12 | 12 | from app.core.transport.http_client import create_http_client |
13 | 13 |
|
@@ -521,6 +521,7 @@ async def manage_announcement_banner(params: FunctionCallParams): |
521 | 521 | action = params.arguments.get("action") |
522 | 522 | description = params.arguments.get("description") |
523 | 523 | background_color = params.arguments.get("background_color", None) |
| 524 | + text_color = params.arguments.get("text_color", None) |
524 | 525 |
|
525 | 526 | # Validate action |
526 | 527 | if not action: |
@@ -561,7 +562,20 @@ async def manage_announcement_banner(params: FunctionCallParams): |
561 | 562 | if match: |
562 | 563 | background_color = match.group(1) |
563 | 564 | 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 |
565 | 579 |
|
566 | 580 | except ValueError as e: |
567 | 581 | logger.error( |
@@ -644,7 +658,7 @@ async def manage_announcement_banner(params: FunctionCallParams): |
644 | 658 | if action == BannerAction.ADD or action == BannerAction.UPDATE: |
645 | 659 | # Format the description with HTML styling |
646 | 660 | formatted_description = format_announcement_html( |
647 | | - description, background_color |
| 661 | + description, background_color, text_color |
648 | 662 | ) |
649 | 663 |
|
650 | 664 | # Update both announcement types with the same formatted content |
@@ -740,6 +754,11 @@ async def manage_announcement_banner(params: FunctionCallParams): |
740 | 754 | "description": "The background color of the announcement banner. Default is #714acd (Light Purple).", |
741 | 755 | "default": "#714acd", |
742 | 756 | }, |
| 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 | + }, |
743 | 762 | }, |
744 | 763 | required=["action"], |
745 | 764 | ) |
|
0 commit comments