import os import argparse import streamlit as st from streamlit_option_menu import option_menu from openfactcheck import OpenFactCheck from openfactcheck.lib import OpenFactCheckConfig from openfactcheck.app.sidebar import sidebar from openfactcheck.app.dialogs import get_secrets from openfactcheck.app.evaluate_response import evaluate_response from openfactcheck.app.evaluate_llm import evaluate_llm from openfactcheck.app.evaluate_factchecker import evaluate_factchecker def parse_args(): parser = argparse.ArgumentParser(description='Initialize OpenFactCheck with custom configuration.') # Add arguments here, example: parser.add_argument("--config-path", type=str, help="Config File Path", default="config.json") # Parse arguments from command line args = parser.parse_args() return args class App: def __init__(self, config_path: str = "config.json"): # Set up Dashboard st.set_page_config(page_title="OpenFactCheck Dashboard", page_icon=":bar_chart:", layout="wide", initial_sidebar_state="collapsed") # Get API Keys st.session_state.api_keys = False # Check if the API keys are already set in the environment variables if os.getenv("OPENAI_API_KEY") and os.getenv("SERPER_API_KEY") and os.getenv("SCRAPER_API_KEY"): st.session_state.api_keys = True else: get_secrets() # Initialize OpenFactCheck @st.cache_resource(show_spinner=False) def init(config_path: str = "config.json"): # Initialize OpenFactCheckConfig config = OpenFactCheckConfig(config_path) ofc = OpenFactCheck(config) return ofc if st.session_state.api_keys: self.ofc = init(config_path) else: self.ofc = None def run(self): # Set up Sidebar sidebar() # Title st.markdown("