DrishtiSharma commited on
Commit
bcc6b48
·
verified ·
1 Parent(s): f596c9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -106
app.py CHANGED
@@ -880,112 +880,6 @@ def multi_agent_debate() -> None:
880
  # Initialize all the session state variables
881
  initialize_session_state_variables()
882
 
883
- with st.sidebar:
884
- st.write("")
885
- st.write("**API Key Selection**")
886
- choice_api = st.sidebar.radio(
887
- label="$\\hspace{0.25em}\\texttt{Choice of API}$",
888
- options=("Your keys", "My keys"),
889
- label_visibility="collapsed",
890
- horizontal=True,
891
- )
892
-
893
- if choice_api == "Your keys":
894
- validity = "(Verified)" if st.session_state.ready else ""
895
- st.write(
896
- "**OpenAI API Key** ",
897
- f"<small>:blue[{validity}]</small>",
898
- unsafe_allow_html=True
899
- )
900
- openai_api_key = st.text_input(
901
- label="$\\textsf{Your OPenAI API Key}$",
902
- type="password",
903
- on_change=check_api_keys,
904
- label_visibility="collapsed",
905
- )
906
- if st.session_state.bing_subscription_validity:
907
- validity = "(Verified)"
908
- else:
909
- validity = ""
910
- st.write(
911
- "**Bing Subscription Key** ",
912
- f"<small>:blue[{validity}]</small>",
913
- unsafe_allow_html=True
914
- )
915
- bing_subscription_key = st.text_input(
916
- label="$\\textsf{Your Bing Subscription Key}$",
917
- type="password",
918
- value="",
919
- on_change=check_api_keys,
920
- label_visibility="collapsed",
921
- )
922
- authentication = True
923
- else:
924
- openai_api_key = st.secrets["OPENAI_API_KEY"]
925
- bing_subscription_key = st.secrets["BING_SUBSCRIPTION_KEY"]
926
- langchain_api_key = st.secrets["LANGCHAIN_API_KEY"]
927
- stored_pin = st.secrets["USER_PIN"]
928
- st.write("**Password**")
929
- user_pin = st.text_input(
930
- label="Enter password", type="password", label_visibility="collapsed"
931
- )
932
- authentication = user_pin == stored_pin
933
-
934
- os.environ["BING_SEARCH_URL"] = "https://api.bing.microsoft.com/v7.0/search"
935
-
936
- if authentication:
937
- if not st.session_state.ready:
938
- if is_openai_api_key_valid(openai_api_key):
939
- os.environ["OPENAI_API_KEY"] = openai_api_key
940
- st.session_state.ready = True
941
-
942
- if choice_api == "My keys":
943
- os.environ["BING_SUBSCRIPTION_KEY"] = bing_subscription_key
944
- st.session_state.bing_subscription_validity = True
945
- os.environ["LANGCHAIN_API_KEY"] = langchain_api_key
946
- current_date = datetime.datetime.now().date()
947
- date_string = str(current_date)
948
- os.environ["LANGCHAIN_PROJECT"] = "agent_debate_" + date_string
949
- else:
950
- if is_bing_subscription_key_valid(bing_subscription_key):
951
- os.environ["BING_SUBSCRIPTION_KEY"] = bing_subscription_key
952
- st.session_state.bing_subscription_validity = True
953
- else:
954
- st.session_state.bing_subscription_validity = False
955
- st.rerun()
956
- else:
957
- st.info(
958
- """
959
- **Enter your OpenAI and Bing Subscription Keys in the sidebar**
960
-
961
- Get an OpenAI API Key [here](https://platform.openai.com/api-keys)
962
- and a Bing Subscription Key [here](https://portal.azure.com/).
963
- You can also follow instructions on
964
- [this site](https://levelup.gitconnected.com/api-tutorial-how-to-use-bing-web-search-api-in-python-4165d5592a7e)
965
- to get your Bing Subscription Key. If you do not plan to search
966
- the internet, there is no need to enter your Bing Subscription key.
967
- """
968
- )
969
- st.image("files/image-3.png")
970
- st.stop()
971
- else:
972
- st.info("**Enter the correct password in the sidebar**")
973
- st.stop()
974
-
975
- with st.sidebar:
976
- if choice_api == "My keys":
977
- st.write("")
978
- st.write("**LangSmith Tracing**")
979
- langsmith = st.radio(
980
- label="LangSmith Tracing",
981
- options=("On", "Off"),
982
- label_visibility="collapsed",
983
- index=1,
984
- horizontal=True
985
- )
986
- os.environ["LANGCHAIN_TRACING_V2"] = (
987
- "true" if langsmith == "On" else "false"
988
- )
989
 
990
  if st.session_state.new_debate:
991
  set_debate()
 
880
  # Initialize all the session state variables
881
  initialize_session_state_variables()
882
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
883
 
884
  if st.session_state.new_debate:
885
  set_debate()