import streamlit as st import jnius_config if not jnius_config.vm_running: jnius_config.set_classpath("/code/CognitiveReasonerLite.jar") from jnius import autoclass # For running Java. See https://pyjnius.readthedocs.io/en/latest/ for documentation. CRL_PACKAGE = "com.optum.cogtech.crl." def make_agent(config_name="agent_demo"): # Start the CRL engine st.session_state["agent"] = st.session_state.Java_Agent() # Configure the decision making decConfig = st.session_state.Java_DecisionConfig(config_name) decConfig.selectAll() st.session_state.agent.addSettings(decConfig) # Configure debug printing st.session_state.agent.logger.disable() st.session_state.agent.logger.setWriteToFile(False) # st.session_state.agent.logger.setEnableLogCycles(True) # st.session_state.agent.logger.setEnableLogContexts(True) # st.session_state.agent.logger.setEnableLogOperators(True) # st.session_state.agent.logger.setEnableLogActivation(True) return decConfig def init(): # Define the Java<->Python interface needed to run the CRL jar st.session_state["Java_ArrayList"] = autoclass('java.util.ArrayList') st.session_state["Java_Agent"] = autoclass(CRL_PACKAGE+"Agent") st.session_state["Java_DecisionConfig"] = autoclass(CRL_PACKAGE+"DecisionConfig") st.session_state["Java_Concept"] = autoclass(CRL_PACKAGE+"Concept") st.session_state["Java_ActionReportActiveConcept"] = autoclass(CRL_PACKAGE+"ActionReportActiveConcept") make_agent() def ReportActiveConceptActionInList(outputAttribute, attributeForReportValue): collection = st.session_state.Java_ArrayList() collection.add(st.session_state.Java_ActionReportActiveConcept(outputAttribute, attributeForReportValue)) return collection