Commit ·
d017932
1
Parent(s): 7f7111d
- error handling: be able to select other brands if the config file doesn't exist yet.
Browse files
Messaging_system/CoreConfig.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
the flow of the Program starts from create_personalized_message function
|
| 3 |
"""
|
| 4 |
-
|
| 5 |
import time
|
| 6 |
from Messaging_system.SnowFlakeConnection import SnowFlakeConn
|
| 7 |
|
|
@@ -75,16 +75,17 @@ class CoreConfig:
|
|
| 75 |
# ===============================================================
|
| 76 |
def get_brand_voice(self):
|
| 77 |
"""
|
| 78 |
-
|
| 79 |
-
:
|
|
|
|
| 80 |
"""
|
| 81 |
-
# assuming your file is named 'example.txt' and is in the same directory
|
| 82 |
file_path = f'Config_files/{self.brand.lower()}_phrases.txt'
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
|
| 87 |
-
|
|
|
|
| 88 |
|
| 89 |
# --------------------------------------------------------------
|
| 90 |
# --------------------------------------------------------------
|
|
|
|
| 1 |
"""
|
| 2 |
the flow of the Program starts from create_personalized_message function
|
| 3 |
"""
|
| 4 |
+
import os
|
| 5 |
import time
|
| 6 |
from Messaging_system.SnowFlakeConnection import SnowFlakeConn
|
| 7 |
|
|
|
|
| 75 |
# ===============================================================
|
| 76 |
def get_brand_voice(self):
|
| 77 |
"""
|
| 78 |
+
Get positive phrases for the brand to instruct the LLM to talk like this.
|
| 79 |
+
Returns:
|
| 80 |
+
str: The brand voice phrases if file exists, otherwise None.
|
| 81 |
"""
|
|
|
|
| 82 |
file_path = f'Config_files/{self.brand.lower()}_phrases.txt'
|
| 83 |
|
| 84 |
+
if not os.path.exists(file_path):
|
| 85 |
+
return None
|
| 86 |
|
| 87 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
| 88 |
+
return f.read()
|
| 89 |
|
| 90 |
# --------------------------------------------------------------
|
| 91 |
# --------------------------------------------------------------
|