doncamilom commited on
Commit
be84066
1 Parent(s): 7281174

api key as internal var

Browse files
Files changed (2) hide show
  1. app.py +17 -21
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,9 +1,5 @@
1
  import os
2
 
3
- # Initialize with fake api key
4
- if 'OPENAI_API_KEY' not in os.environ:
5
- os.environ['OPENAI_API_KEY'] = 'sk-'
6
-
7
  import pandas as pd
8
  import requests
9
  import streamlit as st
@@ -27,19 +23,6 @@ load_dotenv()
27
  ss = st.session_state
28
 
29
 
30
- agent = ChemCrow(
31
- #tools,
32
- model='gpt-4',
33
- temp=0.1,
34
- ).agent_executor
35
-
36
-
37
- #tool_list = pd.Series(
38
- # {f"✅ {t.name}":t.description for t in tools}
39
- #).reset_index()
40
- #tool_list.columns = ['Tool', 'Description']
41
-
42
-
43
  icon = Image.open('assets/logo0.png')
44
  st.set_page_config(
45
  page_title="ChemCrow",
@@ -60,9 +43,6 @@ st.markdown(
60
 
61
  # Session state
62
  # st.session_state['molecule'] = "CCO"
63
- def on_api_key_change():
64
- api_key = ss.get('api_key') or os.getenv('OPENAI_API_KEY')
65
- os.environ["OPENAI_API_KEY"] = api_key
66
 
67
 
68
  # sidebar
@@ -72,7 +52,7 @@ with st.sidebar:
72
 
73
  # Input OpenAI api key
74
  st.markdown('Input your OpenAI API key.')
75
- st.text_input('OpenAI API key', type='password', key='api_key', on_change=on_api_key_change, label_visibility="collapsed")
76
 
77
  # Display available tools
78
  #st.markdown(f"# Available tools: {len(tools)}")
@@ -85,6 +65,22 @@ with st.sidebar:
85
  #)
86
 
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  print(st.session_state)
89
  # Agent execution
90
  if prompt := st.chat_input():
 
1
  import os
2
 
 
 
 
 
3
  import pandas as pd
4
  import requests
5
  import streamlit as st
 
23
  ss = st.session_state
24
 
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  icon = Image.open('assets/logo0.png')
27
  st.set_page_config(
28
  page_title="ChemCrow",
 
43
 
44
  # Session state
45
  # st.session_state['molecule'] = "CCO"
 
 
 
46
 
47
 
48
  # sidebar
 
52
 
53
  # Input OpenAI api key
54
  st.markdown('Input your OpenAI API key.')
55
+ st.text_input('OpenAI API key', type='password', key='api_key', label_visibility="collapsed")
56
 
57
  # Display available tools
58
  #st.markdown(f"# Available tools: {len(tools)}")
 
65
  #)
66
 
67
 
68
+ agent = ChemCrow(
69
+ #tools,
70
+ model='gpt-4',
71
+ temp=0.1,
72
+ api_key=ss.get('api_key')
73
+ ).agent_executor
74
+
75
+
76
+ #tool_list = pd.Series(
77
+ # {f"✅ {t.name}":t.description for t in tools}
78
+ #).reset_index()
79
+ #tool_list.columns = ['Tool', 'Description']
80
+
81
+
82
+
83
+
84
  print(st.session_state)
85
  # Agent execution
86
  if prompt := st.chat_input():
requirements.txt CHANGED
@@ -2,5 +2,5 @@ ipython
2
  paper-scraper @ git+https://github.com/blackadad/paper-scraper.git
3
  streamlit
4
  python-dotenv
5
- chemcrow==0.3.1
6
 
 
2
  paper-scraper @ git+https://github.com/blackadad/paper-scraper.git
3
  streamlit
4
  python-dotenv
5
+ chemcrow==0.3.2
6