Spaces:
Build error
Build error
| import sys | |
| import os | |
| import traceback | |
| import json | |
| import logging | |
| import gradio as gr | |
| sys.path.append(os.path.abspath('common')) | |
| sys.path.append(os.path.abspath('researchsimulation')) | |
| from crewai import Crew, Task, Process | |
| from RespondentAgent import * | |
| from LLMConfig import * | |
| from PanelInterface import * | |
| # Configure logging | |
| logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') | |
| # MAIN | |
| if __name__ == "__main__": | |
| logging.info("Loading environment...") | |
| Config.load_environment(".", "invictus.dev1") | |
| logging.info("Environment loaded. Printing environment:") | |
| Config.print_environment() | |
| logging.info("Initializing processor_llm...") | |
| processor_llm = get_processor_llm_instance() | |
| logging.info("processor_llm initialized.") | |
| logging.info("Initializing respondent_agent_llm...") | |
| respondent_agent_llm = get_respondent_agent_llm_instance() | |
| logging.info("respondent_agent_llm initialised.") | |
| # Load all user profiles from the Excel file | |
| data_dictionary = DataDictionary.generate_dictionary(Config.data_dictionary_file) | |
| logging.info(f"Generated data dictionary: {data_dictionary}") | |
| personality_assessment = PVAssessment.generate_personality_assessment(Config.personality_question_file) | |
| logging.info(f"Generated personality_assessment: {data_dictionary}") | |
| respondent_agent_user_profiles = UserProfile.read_user_profiles_from_excel(Config.respondent_details_file, data_dictionary, personality_assessment) | |
| # Create respondent agents for all profiles | |
| respondent_agents_dict = { | |
| profile.get_field("Demographics", "Name"): RespondentAgent.create( | |
| profile, f"{Config.config_dir}/fastfacts/{profile.ID}_fast_facts.xlsx", respondent_agent_llm | |
| ) | |
| for profile in respondent_agent_user_profiles[:5] | |
| } | |
| logging.info(f"Total agents created: {len(respondent_agents_dict)}") | |
| demo = build_interface(respondent_agents_dict, processor_llm) | |
| logging.info("Launching Gradio interface...") | |
| demo.launch(debug=True) |