File size: 11,824 Bytes
441d880
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48eb5d7
441d880
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2804f1
 
 
 
 
441d880
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48eb5d7
441d880
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
from dotenv import load_dotenv
import os

class Config:
    # === General Environment Info ===
    env_name                           = None
    num_respondents                    = None
    num_focus_groups                   = None

    # === Directories and Files ===
    base_dir                           = None
    config_dir                         = None
    test_result_dir                    = None
    input_dir                          = None
    output_dir                         = None
    respondent_summary_file            = None
    focus_group_summary_file           = None
    respondent_details_file            = None
    data_dictionary_file               = None
    personality_question_file          = None
    personality_scoring_file           = None
    style_tone_question_file           = None
    interview_question_file            = None
    survey_question_file               = None
    interview_validation_files         = None
    hugging_face_excel_file            = None
    
    # === Respondent Agent Configs ===
    respondent_agent_host              = None
    respondent_agent_model             = None
    respondent_agent_api_key           = None
    respondent_agent_url               = None
    respondent_agent_temperature       = None
    respondent_agent_top_p             = None
    respondent_agent_frequency_penalty = None
    respondent_agent_presence_penalty  = None

    # === Processing Agent Configs ===
    processing_agent_host              = None
    processing_agent_model             = None
    processing_agent_api_key           = None
    processing_agent_url               = None
    processing_agent_temperature       = None
    processing_agent_top_p             = None
    processing_agent_frequency_penalty = None
    processing_agent_presence_penalty  = None

    # === Processor Configs ===
    processor_host                     = None
    processor_model                    = None
    processor_api_key                  = None
    processor_url                      = None
    processor_temperature              = None
    processor_top_p                    = None
    processor_frequency_penalty        = None
    processor_presence_penalty         = None

    
    # Function to load the environment variables based on the given environment name
    @classmethod
    def load_environment(cls, base_dir, my_env_name):
        # Determine the path to the .env file based on the environment name
        env_file = f'{base_dir}/config/{my_env_name}.env'  # Update the base path as needed
        
        # Load the environment variables from the specified .env file
        load_dotenv(dotenv_path=env_file)

        cls.base_dir                           = base_dir
        cls.env_name                           = my_env_name
        cls.num_respondents                    = int(os.getenv('NUM_RESPONDENTS', 0))
        cls.num_focus_groups                   = int(os.getenv('NUM_FOCUS_GROUPS', 0))
        
        # Construct paths based on BASE_DIR and subdirectories/filenames
        cls.config_dir                         = f"{base_dir}/{os.getenv('CONFIG_SUBDIR')}"
        cls.test_result_dir                    = f"{base_dir}/{os.getenv('TEST_SUBDIR')}"
        cls.input_dir                          = f"{base_dir}/{os.getenv('INPUT_SUBDIR')}"
        cls.output_dir                         = f"{base_dir}/{os.getenv('OUTPUT_SUBDIR')}"
        cls.respondent_summary_file            = f"{cls.config_dir}/{os.getenv('RESPONDENT_SUMMARY_FILE')}"
        cls.focus_group_summary_file           = f"{cls.config_dir}/{os.getenv('FOCUS_GROUP_SUMMARY_FILE')}"
        cls.respondent_details_file            = f"{cls.config_dir}/{os.getenv('RESPONDENT_DETAILS_FILE')}"
        cls.data_dictionary_file               = f"{cls.config_dir}/{os.getenv('DATA_DICTIONARY_FILE')}"
        cls.personality_question_file          = f"{cls.config_dir}/{os.getenv('PERSONALITY_QUESTION_FILE')}"
        cls.personality_scoring_file           = f"{cls.config_dir}/{os.getenv('PERSONALITY_SCORING_FILE')}"
        cls.style_tone_question_file           = f"{cls.config_dir}/{os.getenv('STYLE_TONE_QUESTION_FILE')}"
        cls.interview_question_file            = f"{cls.config_dir}/{os.getenv('INTERVIEW_QUESTION_FILE')}"
        cls.survey_question_file               = f"{cls.config_dir}/{os.getenv('SURVEY_QUESTION_FILE')}"
        cls.interview_validation_files         = f"{cls.config_dir}/{os.getenv('INTERVIEW_VALIDATION_FILES')}"
        
        # Respondent Agent Model: Load the environment variables, API keys, and parameters
        cls.respondent_agent_host              = os.getenv(os.getenv("RESPONDENT_AGENT_HOST"))
        cls.respondent_agent_model             = os.getenv(os.getenv("RESPONDENT_AGENT_MODEL"))        
        
        respondent_agent_prefix                = (lambda: os.getenv('RESPONDENT_AGENT_HOST').replace('_AGENT_HOST', ''))()
        cls.respondent_agent_api_key           = os.getenv(f"{respondent_agent_prefix}_API_KEY")
        cls.respondent_agent_url               = os.getenv(f"{respondent_agent_prefix}_URL")

        cls.respondent_agent_temperature       = float(os.getenv(f"{respondent_agent_prefix}_TEMPERATURE", 0.0))
        cls.respondent_agent_top_p             = float(os.getenv(f"{respondent_agent_prefix}_TOP_P", 0.0))
        cls.respondent_agent_frequency_penalty = float(os.getenv(f"{respondent_agent_prefix}_FREQUENCY_PENALTY", 0.0))
        cls.respondent_agent_presence_penalty  = float(os.getenv(f"{respondent_agent_prefix}_PRESENCE_PENALTY", 0.0))
        
        # Processing Agent Model: Load the environment variables, API keys, and parameters
        cls.processing_agent_host              = os.getenv(os.getenv("PROCESSING_AGENT_HOST"))
        cls.processing_agent_model             = os.getenv(os.getenv("PROCESSING_AGENT_MODEL"))        
        
        processing_agent_prefix                = (lambda: os.getenv('PROCESSING_AGENT_HOST').replace('_AGENT_HOST', ''))()
        cls.processing_agent_api_key           = os.getenv(f"{processing_agent_prefix}_API_KEY")
        cls.processing_agent_url               = os.getenv(f"{processing_agent_prefix}_URL")

        cls.processing_agent_temperature       = float(os.getenv(f"{processing_agent_prefix}_TEMPERATURE", 0.0))
        cls.processing_agent_top_p             = float(os.getenv(f"{processing_agent_prefix}_TOP_P", 0.0))
        cls.processing_agent_frequency_penalty = float(os.getenv(f"{processing_agent_prefix}_FREQUENCY_PENALTY", 0.0))
        cls.processing_agent_presence_penalty  = float(os.getenv(f"{processing_agent_prefix}_PRESENCE_PENALTY", 0.0))

        # Processor Model: Load the environment variables, API keys, and parameters
        cls.processor_host                     = os.getenv(os.getenv("PROCESSOR_HOST"))
        cls.processor_model                    = os.getenv(os.getenv("PROCESSOR_MODEL"))        
        
        processor_prefix                       = (lambda: os.getenv('PROCESSOR_HOST').replace('_AGENT_HOST', ''))()
        cls.processor_api_key                  = os.getenv(f"{processor_prefix}_API_KEY")
        cls.processor_url                      = os.getenv(f"{processor_prefix}_URL")

        cls.processor_temperature              = float(os.getenv(f"{processor_prefix}_TEMPERATURE", 0.0))
        cls.processor_top_p                    = float(os.getenv(f"{processor_prefix}_TOP_P", 0.0))
        cls.processor_frequency_penalty        = float(os.getenv(f"{processor_prefix}_FREQUENCY_PENALTY", 0.0))
        cls.processor_presence_penalty         = float(os.getenv(f"{processor_prefix}_PRESENCE_PENALTY", 0.0))

        hugging_face_excel_env = os.getenv('HUGGING_FACE_EXCEL_FILE', 'hugging_face_details.xlsx')
        if not os.path.isabs(hugging_face_excel_env):
            cls.hugging_face_excel_file = os.path.join(cls.config_dir, hugging_face_excel_env)
        else:
            cls.hugging_face_excel_file = hugging_face_excel_env
    @classmethod
    def print_environment(cls):

        print("ENVIRONMENT CONFIGURATION")
        print(f"Environment Name:                   {cls.env_name}")
        print(f"Number of Respondents:              {cls.num_respondents}")
        print(f"Number of Focus Groups:             {cls.num_focus_groups}")

        print("\nDIRECTORIES:")
        print(f"Base Directory:                     {cls.base_dir}")
        print(f"Config Directory:                   {cls.config_dir}")
        print(f"Test Result Directory:              {cls.test_result_dir}")
        print(f"Input Directory:                    {cls.input_dir}")
        print(f"Output Directory:                   {cls.output_dir}")

        print("\nFILES:")
        print(f"Respondent Summary File:            {cls.respondent_summary_file}")
        print(f"Focus Group Summary File:           {cls.focus_group_summary_file}")
        print(f"Personality Question File:          {cls.personality_question_file}")        
        print(f"Respondent Details File:            {cls.respondent_details_file}")
        print(f"Data Dictionary File:               {cls.data_dictionary_file}")
        print(f"Personality Scoring File:           {cls.personality_scoring_file}")
        print(f"Style Tone Question File:           {cls.style_tone_question_file}")
        print(f"Interview Question File:            {cls.interview_question_file}")
        print(f"Survey Question File:               {cls.survey_question_file}")
        print(f"Interview Validation Files:         {cls.interview_validation_files}")
        print(f"Hugging Face Excel File:            {cls.hugging_face_excel_file}")
                
        print("\nRESPONDENT AGENT CONFIGS")
        print(f"Respondent Agent Host:              {cls.respondent_agent_host}")
        print(f"Respondent Agent Model:             {cls.respondent_agent_model}")
        print(f"Respondent Agent API Key:           {cls.respondent_agent_api_key}")
        print(f"Respondent Agent URL:               {cls.respondent_agent_url}")
        print(f"Respondent Agent Temperature:       {cls.respondent_agent_temperature}")
        print(f"Respondent Agent Top P:             {cls.respondent_agent_top_p}")
        print(f"Respondent Agent Frequency Penalty: {cls.respondent_agent_frequency_penalty}")
        print(f"Respondent Agent Presence Penalty:  {cls.respondent_agent_presence_penalty}")
        
        print("\nPROCESSING AGENT CONFIGS")
        print(f"Processing Agent Host:              {cls.processing_agent_host}")
        print(f"Processing Agent Name:              {cls.processing_agent_model}")
        print(f"Processing Agent API Key:           {cls.processing_agent_api_key}")
        print(f"Processing Agent URL:               {cls.processing_agent_url}")
        print(f"Processing Agent Temperature:       {cls.processing_agent_temperature}")
        print(f"Processing Agent Top P:             {cls.processing_agent_top_p}")
        print(f"Processing Agent Frequency Penalty: {cls.processing_agent_frequency_penalty}")
        print(f"Processing Agent Presence Penalty:  {cls.processing_agent_presence_penalty}")

        print("\nPROCESSOR CONFIGS")
        print(f"Processor Host:                     {cls.processor_host}")
        print(f"Processor Name:                     {cls.processor_model}")
        print(f"Processor API Key:                  {cls.processor_api_key}")
        print(f"Processor URL:                      {cls.processor_url}")
        print(f"Processor Temperature:              {cls.processor_temperature}")
        print(f"Processor Top P:                    {cls.processor_top_p}")
        print(f"Processor Frequency Penalty:        {cls.processor_frequency_penalty}")
        print(f"Processor Presence Penalty:         {cls.processor_presence_penalty}")